@umijs/plugin-docs 4.0.0-canary.20230427.1 → 4.0.0-canary.20230510.1

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 CHANGED
@@ -16,7 +16,14 @@ 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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
20
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
28
 
22
29
  // src/compiler.ts
@@ -38,9 +45,13 @@ var rehypePrettyCodeOptions = {
38
45
  node.children = [{ type: "text", value: " " }];
39
46
  }
40
47
  },
48
+ // 允许高亮代码行
49
+ // 对于高亮的代码行,设置为 highlighted 样式表类
41
50
  onVisitHighlightedLine(node) {
42
51
  node.properties.className.push("highlighted");
43
52
  },
53
+ // 允许高亮代码文字
54
+ // 对于高亮的代码文字,设置为 word 样式表类
44
55
  onVisitHighlightedWord(node) {
45
56
  node.properties.className = ["word"];
46
57
  }
@@ -57,14 +68,16 @@ async function compile(opts) {
57
68
  });
58
69
  try {
59
70
  let result = String(await compiler.process(opts.content));
60
- result = result.replace("function MDXContent(props = {}) {", `
71
+ result = result.replace(
72
+ "function MDXContent(props = {}) {",
73
+ `
61
74
  import { useEffect } from 'react';
62
75
 
63
76
  function MDXContent(props = {}) {
64
77
 
65
78
  useEffect(() => {
66
79
  if (window.location.hash.length !== 0) {
67
- // \u4E3A\u4E86\u53F3\u4FA7\u5185\u5BB9\u533A\u80FD\u6B63\u5E38\u8DF3\u8F6C
80
+ // 为了右侧内容区能正常跳转
68
81
  const hash = decodeURIComponent(window.location.hash);
69
82
  setTimeout(() => {
70
83
  document.getElementById(hash.slice(1))?.scrollIntoView();
@@ -78,12 +91,15 @@ function MDXContent(props = {}) {
78
91
  });
79
92
  }, []);
80
93
 
81
- `);
94
+ `
95
+ );
82
96
  return { result };
83
97
  } catch (e) {
84
98
  import_plugin_utils.logger.error(e.reason);
85
99
  import_plugin_utils.logger.error(`Above error occurred in ${opts.fileName} at line ${e.line}`);
86
- import_plugin_utils.logger.error(opts.content.split("\n").filter((_, i) => i == e.line - 1).join("\n"));
100
+ import_plugin_utils.logger.error(
101
+ opts.content.split("\n").filter((_, i) => i == e.line - 1).join("\n")
102
+ );
87
103
  import_plugin_utils.logger.error(" ".repeat(e.column - 1) + "^");
88
104
  if (process.env.NODE_ENV === "production") {
89
105
  throw new Error("compile error", { cause: e });
package/dist/index.js CHANGED
@@ -16,7 +16,14 @@ 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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
20
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
28
 
22
29
  // src/index.ts
@@ -82,7 +89,10 @@ var src_default = (api) => {
82
89
  for (const route in r) {
83
90
  if (r[route].path.match(/^[a-z]{2}-[A-Z]{2}\/.*/))
84
91
  continue;
85
- const defaultLangFile = r[route].file.replace(/(.[a-z]{2}-[A-Z]{2})?.md$/, "");
92
+ const defaultLangFile = r[route].file.replace(
93
+ /(.[a-z]{2}-[A-Z]{2})?.md$/,
94
+ ""
95
+ );
86
96
  Object.keys(locales).map((l) => {
87
97
  if (r[defaultLangFile] && !r[defaultLangFile + "." + l]) {
88
98
  r[defaultLangFile + "." + l] = {
@@ -111,7 +121,9 @@ var src_default = (api) => {
111
121
  api.writeTmpFile({
112
122
  path: "index.ts",
113
123
  content: `
114
- export { ${exports.filter((item) => !item.startsWith("$")).join(", ")} } from '${(0, import_utils.winPath)(require.resolve("../client/theme-doc/index.ts"))}';
124
+ export { ${exports.filter((item) => !item.startsWith("$")).join(", ")} } from '${(0, import_utils.winPath)(
125
+ require.resolve("../client/theme-doc/index.ts")
126
+ )}';
115
127
  `
116
128
  });
117
129
  api.writeTmpFile({
@@ -119,7 +131,9 @@ export { ${exports.filter((item) => !item.startsWith("$")).join(", ")} } from '$
119
131
  content: `
120
132
  import React from 'react';
121
133
  import { useOutlet, useAppData, useLocation, Link, history } from 'umi';
122
- import { $Layout as Layout } from '${(0, import_utils.winPath)(require.resolve("../client/theme-doc/index.ts"))}';
134
+ import { $Layout as Layout } from '${(0, import_utils.winPath)(
135
+ require.resolve("../client/theme-doc/index.ts")
136
+ )}';
123
137
  ${themeExists ? `import themeConfig from '${themeConfigPath}'` : `const themeConfig = {}`}
124
138
 
125
139
  ${injectLocale}
@@ -150,7 +164,11 @@ export default () => {
150
164
  });
151
165
  };
152
166
  function withTmpPath(opts) {
153
- return (0, import_path.join)(opts.api.paths.absTmpPath, opts.api.plugin.key && !opts.noPluginDir ? `plugin-${opts.api.plugin.key}` : "", opts.path);
167
+ return (0, import_path.join)(
168
+ opts.api.paths.absTmpPath,
169
+ opts.api.plugin.key && !opts.noPluginDir ? `plugin-${opts.api.plugin.key}` : "",
170
+ opts.path
171
+ );
154
172
  }
155
173
  // Annotate the CommonJS export names for ESM import in node:
156
174
  0 && (module.exports = {});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/plugin-docs",
3
- "version": "4.0.0-canary.20230427.1",
3
+ "version": "4.0.0-canary.20230510.1",
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.0-canary.20230427.1"
36
+ "umi": "4.0.0-canary.20230510.1"
37
37
  },
38
38
  "publishConfig": {
39
39
  "access": "public"