@umijs/plugin-docs 4.0.0-canary.20220429.4 → 4.0.0-canary.20220506.3

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
@@ -1,20 +1,11 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
14
5
  Object.defineProperty(exports, "__esModule", { value: true });
15
6
  exports.compile = void 0;
16
- const plugin_utils_1 = require("umi/plugin-utils");
17
7
  const rehype_pretty_code_1 = __importDefault(require("rehype-pretty-code"));
8
+ const plugin_utils_1 = require("umi/plugin-utils");
18
9
  // @ts-ignore
19
10
  const mdx_1 = require("../compiled/@mdx-js/mdx");
20
11
  // @ts-ignore
@@ -42,16 +33,15 @@ const rehypePrettyCodeOptions = {
42
33
  node.properties.className = ['word'];
43
34
  },
44
35
  };
45
- function compile(opts) {
46
- return __awaiter(this, void 0, void 0, function* () {
47
- const compiler = (0, mdx_1.createProcessor)({
48
- jsx: true,
49
- remarkPlugins: [remark_gfm_1.default],
50
- rehypePlugins: [rehype_slug_1.default, [rehype_pretty_code_1.default, rehypePrettyCodeOptions]],
51
- });
52
- try {
53
- let result = String(yield compiler.process(opts.content));
54
- result = result.replace('function MDXContent(props = {}) {', `
36
+ async function compile(opts) {
37
+ const compiler = (0, mdx_1.createProcessor)({
38
+ jsx: true,
39
+ remarkPlugins: [remark_gfm_1.default],
40
+ rehypePlugins: [rehype_slug_1.default, [rehype_pretty_code_1.default, rehypePrettyCodeOptions]],
41
+ });
42
+ try {
43
+ let result = String(await compiler.process(opts.content));
44
+ result = result.replace('function MDXContent(props = {}) {', `
55
45
  import { useEffect } from 'react';
56
46
 
57
47
  function MDXContent(props = {}) {
@@ -70,18 +60,17 @@ function MDXContent(props = {}) {
70
60
  }, []);
71
61
 
72
62
  `);
73
- return { result };
74
- }
75
- catch (e) {
76
- plugin_utils_1.logger.error(e.reason);
77
- plugin_utils_1.logger.error(`Above error occurred in ${opts.fileName} at line ${e.line}`);
78
- plugin_utils_1.logger.error(opts.content
79
- .split('\n')
80
- .filter((_, i) => i == e.line - 1)
81
- .join('\n'));
82
- plugin_utils_1.logger.error(' '.repeat(e.column - 1) + '^');
83
- return { result: '' };
84
- }
85
- });
63
+ return { result };
64
+ }
65
+ catch (e) {
66
+ plugin_utils_1.logger.error(e.reason);
67
+ plugin_utils_1.logger.error(`Above error occurred in ${opts.fileName} at line ${e.line}`);
68
+ plugin_utils_1.logger.error(opts.content
69
+ .split('\n')
70
+ .filter((_, i) => i == e.line - 1)
71
+ .join('\n'));
72
+ plugin_utils_1.logger.error(' '.repeat(e.column - 1) + '^');
73
+ return { result: '' };
74
+ }
86
75
  }
87
76
  exports.compile = compile;
package/dist/index.js CHANGED
@@ -44,7 +44,10 @@ exports.default = (api) => {
44
44
  });
45
45
  }
46
46
  api.modifyDefaultConfig((memo) => {
47
- memo.conventionRoutes = Object.assign(Object.assign({}, memo.conventionRoutes), { base: (0, path_1.join)(api.cwd, 'docs') });
47
+ memo.conventionRoutes = {
48
+ ...memo.conventionRoutes,
49
+ base: (0, path_1.join)(api.cwd, 'docs'),
50
+ };
48
51
  memo.mdx = {
49
52
  loader: require.resolve('./loader'),
50
53
  loaderOptions: {},
@@ -84,7 +87,10 @@ exports.default = (api) => {
84
87
  const defaultLangFile = r[route].file.replace(/(.[a-z]{2}-[A-Z]{2})?.md$/, '');
85
88
  Object.keys(locales).map((l) => {
86
89
  if (r[defaultLangFile] && !r[defaultLangFile + '.' + l]) {
87
- r[defaultLangFile + '.' + l] = Object.assign(Object.assign({}, r[defaultLangFile]), { path: `/${l}/${r[defaultLangFile].path}` });
90
+ r[defaultLangFile + '.' + l] = {
91
+ ...r[defaultLangFile],
92
+ path: `/${l}/${r[defaultLangFile].path}`,
93
+ };
88
94
  }
89
95
  });
90
96
  }
package/dist/loader.js CHANGED
@@ -1,33 +1,22 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  const compiler_1 = require("./compiler");
13
- function default_1(content) {
14
- return __awaiter(this, void 0, void 0, function* () {
15
- // @ts-ignore
16
- const filename = this.resourcePath;
17
- // @ts-ignore
18
- const callback = this.async();
19
- try {
20
- const { result } = yield (0, compiler_1.compile)({
21
- content,
22
- fileName: filename,
23
- });
24
- return callback(null, result);
25
- }
26
- catch (e) {
27
- const err = e;
28
- e.message = `${filename}: ${e.message}`;
29
- throw err;
30
- }
31
- });
4
+ async function default_1(content) {
5
+ // @ts-ignore
6
+ const filename = this.resourcePath;
7
+ // @ts-ignore
8
+ const callback = this.async();
9
+ try {
10
+ const { result } = await (0, compiler_1.compile)({
11
+ content,
12
+ fileName: filename,
13
+ });
14
+ return callback(null, result);
15
+ }
16
+ catch (e) {
17
+ const err = e;
18
+ e.message = `${filename}: ${e.message}`;
19
+ throw err;
20
+ }
32
21
  }
33
22
  exports.default = default_1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/plugin-docs",
3
- "version": "4.0.0-canary.20220429.4",
3
+ "version": "4.0.0-canary.20220506.3",
4
4
  "description": "@umijs/plugin-docs",
5
5
  "homepage": "https://github.com/umijs/umi-next/tree/master/packages/plugin-docs#readme",
6
6
  "bugs": "https://github.com/umijs/umi-next/issues",
@@ -39,7 +39,7 @@
39
39
  "rehype-slug": "5.0.1",
40
40
  "remark-gfm": "^3.0.1",
41
41
  "tailwindcss": "^3.0.23",
42
- "umi": "4.0.0-canary.20220429.4"
42
+ "umi": "4.0.0-canary.20220506.3"
43
43
  },
44
44
  "publishConfig": {
45
45
  "access": "public"