@umijs/plugin-docs 4.0.67 → 4.0.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compiler.js +13 -5
- package/dist/index.js +19 -5
- package/package.json +2 -2
package/dist/compiler.js
CHANGED
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/compiler.ts
|
|
@@ -57,14 +60,16 @@ async function compile(opts) {
|
|
|
57
60
|
});
|
|
58
61
|
try {
|
|
59
62
|
let result = String(await compiler.process(opts.content));
|
|
60
|
-
result = result.replace(
|
|
63
|
+
result = result.replace(
|
|
64
|
+
"function MDXContent(props = {}) {",
|
|
65
|
+
`
|
|
61
66
|
import { useEffect } from 'react';
|
|
62
67
|
|
|
63
68
|
function MDXContent(props = {}) {
|
|
64
69
|
|
|
65
70
|
useEffect(() => {
|
|
66
71
|
if (window.location.hash.length !== 0) {
|
|
67
|
-
//
|
|
72
|
+
// 为了右侧内容区能正常跳转
|
|
68
73
|
const hash = decodeURIComponent(window.location.hash);
|
|
69
74
|
setTimeout(() => {
|
|
70
75
|
document.getElementById(hash.slice(1))?.scrollIntoView();
|
|
@@ -78,12 +83,15 @@ function MDXContent(props = {}) {
|
|
|
78
83
|
});
|
|
79
84
|
}, []);
|
|
80
85
|
|
|
81
|
-
`
|
|
86
|
+
`
|
|
87
|
+
);
|
|
82
88
|
return { result };
|
|
83
89
|
} catch (e) {
|
|
84
90
|
import_plugin_utils.logger.error(e.reason);
|
|
85
91
|
import_plugin_utils.logger.error(`Above error occurred in ${opts.fileName} at line ${e.line}`);
|
|
86
|
-
import_plugin_utils.logger.error(
|
|
92
|
+
import_plugin_utils.logger.error(
|
|
93
|
+
opts.content.split("\n").filter((_, i) => i == e.line - 1).join("\n")
|
|
94
|
+
);
|
|
87
95
|
import_plugin_utils.logger.error(" ".repeat(e.column - 1) + "^");
|
|
88
96
|
if (process.env.NODE_ENV === "production") {
|
|
89
97
|
throw new Error("compile error", { cause: e });
|
package/dist/index.js
CHANGED
|
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
20
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
24
|
|
|
22
25
|
// src/index.ts
|
|
@@ -82,7 +85,10 @@ var src_default = (api) => {
|
|
|
82
85
|
for (const route in r) {
|
|
83
86
|
if (r[route].path.match(/^[a-z]{2}-[A-Z]{2}\/.*/))
|
|
84
87
|
continue;
|
|
85
|
-
const defaultLangFile = r[route].file.replace(
|
|
88
|
+
const defaultLangFile = r[route].file.replace(
|
|
89
|
+
/(.[a-z]{2}-[A-Z]{2})?.md$/,
|
|
90
|
+
""
|
|
91
|
+
);
|
|
86
92
|
Object.keys(locales).map((l) => {
|
|
87
93
|
if (r[defaultLangFile] && !r[defaultLangFile + "." + l]) {
|
|
88
94
|
r[defaultLangFile + "." + l] = {
|
|
@@ -111,7 +117,9 @@ var src_default = (api) => {
|
|
|
111
117
|
api.writeTmpFile({
|
|
112
118
|
path: "index.ts",
|
|
113
119
|
content: `
|
|
114
|
-
export { ${exports.filter((item) => !item.startsWith("$")).join(", ")} } from '${(0, import_utils.winPath)(
|
|
120
|
+
export { ${exports.filter((item) => !item.startsWith("$")).join(", ")} } from '${(0, import_utils.winPath)(
|
|
121
|
+
require.resolve("../client/theme-doc/index.ts")
|
|
122
|
+
)}';
|
|
115
123
|
`
|
|
116
124
|
});
|
|
117
125
|
api.writeTmpFile({
|
|
@@ -119,7 +127,9 @@ export { ${exports.filter((item) => !item.startsWith("$")).join(", ")} } from '$
|
|
|
119
127
|
content: `
|
|
120
128
|
import React from 'react';
|
|
121
129
|
import { useOutlet, useAppData, useLocation, Link, history } from 'umi';
|
|
122
|
-
import { $Layout as Layout } from '${(0, import_utils.winPath)(
|
|
130
|
+
import { $Layout as Layout } from '${(0, import_utils.winPath)(
|
|
131
|
+
require.resolve("../client/theme-doc/index.ts")
|
|
132
|
+
)}';
|
|
123
133
|
${themeExists ? `import themeConfig from '${themeConfigPath}'` : `const themeConfig = {}`}
|
|
124
134
|
|
|
125
135
|
${injectLocale}
|
|
@@ -150,7 +160,11 @@ export default () => {
|
|
|
150
160
|
});
|
|
151
161
|
};
|
|
152
162
|
function withTmpPath(opts) {
|
|
153
|
-
return (0, import_path.join)(
|
|
163
|
+
return (0, import_path.join)(
|
|
164
|
+
opts.api.paths.absTmpPath,
|
|
165
|
+
opts.api.plugin.key && !opts.noPluginDir ? `plugin-${opts.api.plugin.key}` : "",
|
|
166
|
+
opts.path
|
|
167
|
+
);
|
|
154
168
|
}
|
|
155
169
|
// Annotate the CommonJS export names for ESM import in node:
|
|
156
170
|
0 && (module.exports = {});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/plugin-docs",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.69",
|
|
4
4
|
"description": "@umijs/plugin-docs",
|
|
5
5
|
"homepage": "https://github.com/umijs/umi/tree/master/packages/plugin-docs#readme",
|
|
6
6
|
"bugs": "https://github.com/umijs/umi/issues",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"rehype-slug": "5.0.1",
|
|
34
34
|
"remark-gfm": "^3.0.1",
|
|
35
35
|
"tailwindcss": "^3.2.4",
|
|
36
|
-
"umi": "4.0.
|
|
36
|
+
"umi": "4.0.69"
|
|
37
37
|
},
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"access": "public"
|