@umijs/plugin-docs 4.0.0-rc.14 → 4.0.0-rc.15
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/client/theme-doc/LangSwitch.tsx +3 -1
- package/client/theme-doc/Layout.tsx +2 -1
- package/client/theme-doc/Search.tsx +1 -0
- package/client/theme-doc/components/Announcement.tsx +1 -0
- package/client/theme-doc/firefox-polyfill.css +4 -4
- package/client/theme-doc/useLanguage.ts +7 -1
- package/dist/compiler.d.ts +1 -0
- package/dist/compiler.js +20 -18
- package/dist/index.js +8 -2
- package/dist/loader.js +17 -27
- package/package.json +2 -2
|
@@ -17,7 +17,7 @@ export default () => {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
function handleClick() {
|
|
20
|
-
if (!currentLanguage) return;
|
|
20
|
+
if (!currentLanguage || languages.length === 1) return;
|
|
21
21
|
if (languages.length === 2) {
|
|
22
22
|
switchLanguage(
|
|
23
23
|
languages[0].locale === currentLanguage.locale
|
|
@@ -29,6 +29,8 @@ export default () => {
|
|
|
29
29
|
setExpanded((e) => !e);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
if (!currentLanguage || languages.length === 1) return null;
|
|
33
|
+
|
|
32
34
|
return (
|
|
33
35
|
<div>
|
|
34
36
|
<div
|
|
@@ -20,7 +20,8 @@ export default (props: any) => {
|
|
|
20
20
|
|
|
21
21
|
function updateBlur() {
|
|
22
22
|
if (!offset || !blur) return;
|
|
23
|
-
blur.backgroundPosition =
|
|
23
|
+
blur.backgroundPosition =
|
|
24
|
+
`0px ` + `calc(var(--anchor-offset) + ${-window.scrollY + 64}px)`;
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
document.addEventListener('scroll', updateBlur, false), updateBlur();
|
|
@@ -102,6 +102,7 @@ export default () => {
|
|
|
102
102
|
<components.Link
|
|
103
103
|
to={(isFromPath ? currentLanguage?.locale : '') + r.href}
|
|
104
104
|
key={i}
|
|
105
|
+
onClick={() => (document.activeElement as HTMLElement)?.blur()}
|
|
105
106
|
className="group outline-none search-result"
|
|
106
107
|
onFocus={() => setIsFocused(true)}
|
|
107
108
|
onBlur={() => setIsFocused(false)}
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
.g-glossy-firefox-cover {
|
|
13
13
|
display: block;
|
|
14
14
|
position: fixed;
|
|
15
|
-
top:
|
|
15
|
+
top: 0;
|
|
16
16
|
width: 100%;
|
|
17
|
-
height: 72px;
|
|
17
|
+
height: calc(var(--anchor-offset) + 72px);
|
|
18
18
|
z-index: 22;
|
|
19
19
|
background-color: white;
|
|
20
20
|
}
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
display: block;
|
|
24
24
|
position: fixed;
|
|
25
25
|
width: 100%;
|
|
26
|
-
top:
|
|
27
|
-
height: 72px;
|
|
26
|
+
top: 0;
|
|
27
|
+
height: calc(var(--anchor-offset) + 72px);
|
|
28
28
|
z-index: 24;
|
|
29
29
|
background: -moz-element(#article-body) no-repeat top;
|
|
30
30
|
filter: blur(10px);
|
|
@@ -57,7 +57,13 @@ function useLanguage(): useLanguageResult {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
function render(key: string) {
|
|
60
|
-
if (!
|
|
60
|
+
if (!themeConfig.locales || Object.keys(themeConfig.locales).length === 0)
|
|
61
|
+
return key;
|
|
62
|
+
if (!currentLanguage) {
|
|
63
|
+
return (
|
|
64
|
+
themeConfig.locales[Object.keys(themeConfig.locales)[0]].key || key
|
|
65
|
+
);
|
|
66
|
+
}
|
|
61
67
|
if (!themeConfig.locales[currentLanguage.locale]) return key;
|
|
62
68
|
return themeConfig.locales[currentLanguage.locale][key] || key;
|
|
63
69
|
}
|
package/dist/compiler.d.ts
CHANGED
package/dist/compiler.js
CHANGED
|
@@ -1,18 +1,10 @@
|
|
|
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;
|
|
7
|
+
const plugin_utils_1 = require("umi/plugin-utils");
|
|
16
8
|
const rehype_pretty_code_1 = __importDefault(require("rehype-pretty-code"));
|
|
17
9
|
// @ts-ignore
|
|
18
10
|
const mdx_1 = require("../compiled/@mdx-js/mdx");
|
|
@@ -41,14 +33,14 @@ const rehypePrettyCodeOptions = {
|
|
|
41
33
|
node.properties.className = ['word'];
|
|
42
34
|
},
|
|
43
35
|
};
|
|
44
|
-
function compile(opts) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
let result = String(
|
|
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));
|
|
52
44
|
result = result.replace('function MDXContent(props = {}) {', `
|
|
53
45
|
import { useEffect } from 'react';
|
|
54
46
|
|
|
@@ -69,6 +61,16 @@ function MDXContent(props = {}) {
|
|
|
69
61
|
|
|
70
62
|
`);
|
|
71
63
|
return { result };
|
|
72
|
-
}
|
|
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
|
+
}
|
|
73
75
|
}
|
|
74
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 =
|
|
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] =
|
|
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,32 +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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
});
|
|
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
|
+
}
|
|
31
21
|
}
|
|
32
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-rc.
|
|
3
|
+
"version": "4.0.0-rc.15",
|
|
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-rc.
|
|
42
|
+
"umi": "4.0.0-rc.15"
|
|
43
43
|
},
|
|
44
44
|
"publishConfig": {
|
|
45
45
|
"access": "public"
|