@rspress/core 2.0.0-rc.2 → 2.0.0-rc.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/{0~7675.989ee664.js → 0~7675.723d12b2.js} +17 -14
- package/dist/{5313.6594aba0.js → 3521.56e42d70.js} +0 -7
- package/dist/{5485.2a0273cf.js → 5485.077f14ff.js} +1 -1
- package/dist/{7805.cadab34e.js → 9643.f109822d.js} +2 -1
- package/dist/_private/react/render.js +17 -4
- package/dist/cli/config/loadConfigFile.js +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/eject-theme/components/Badge/index.scss +1 -0
- package/dist/eject-theme/components/Banner/index.tsx +3 -1
- package/dist/eject-theme/components/Callout/index.tsx +8 -2
- package/dist/eject-theme/components/CodeBlock/index.scss +8 -6
- package/dist/eject-theme/components/CodeBlock/index.tsx +4 -0
- package/dist/eject-theme/components/CodeBlockRuntime/index.tsx +50 -11
- package/dist/eject-theme/components/DocContent/doc.scss +1 -1
- package/dist/eject-theme/components/DocContent/docComponents/pre.tsx +2 -1
- package/dist/eject-theme/components/DocContent/index.tsx +21 -4
- package/dist/eject-theme/components/DocFooter/index.tsx +1 -6
- package/dist/eject-theme/components/HoverGroup/index.scss +1 -1
- package/dist/eject-theme/components/LastUpdated/index.tsx +8 -1
- package/dist/eject-theme/components/Link/index.tsx +9 -2
- package/dist/eject-theme/components/NavScreen/NavScreenLangs.scss +6 -0
- package/dist/eject-theme/components/NavScreen/NavScreenLangs.tsx +23 -9
- package/dist/eject-theme/components/NavScreen/NavScreenVersions.scss +6 -0
- package/dist/eject-theme/components/NavScreen/NavScreenVersions.tsx +22 -9
- package/dist/eject-theme/components/Overview/index.tsx +1 -6
- package/dist/eject-theme/components/{Overview/OverviewGroup.scss → OverviewGroup/index.scss} +66 -12
- package/dist/eject-theme/components/{Overview/OverviewGroup.tsx → OverviewGroup/index.tsx} +50 -3
- package/dist/eject-theme/components/Search/logic/util.test.ts +1 -1
- package/dist/eject-theme/components/Tabs/index.scss +12 -4
- package/dist/eject-theme/components/Tabs/index.tsx +16 -0
- package/dist/eject-theme/components/Tag/index.tsx +84 -5
- package/dist/index.js +2 -2
- package/dist/node/PluginDriver.js +3 -4
- package/dist/node/auto-nav-sidebar/index.js +1 -1
- package/dist/node/auto-nav-sidebar/normalize.js +11 -9
- package/dist/node/auto-nav-sidebar/utils.js +1 -1
- package/dist/node/constants.d.ts +1 -0
- package/dist/node/constants.js +3 -2
- package/dist/node/eject.js +5 -5
- package/dist/node/initRsbuild.js +14 -6
- package/dist/node/last-updated/index.js +1 -1
- package/dist/node/mdx/loader.js +2 -1
- package/dist/node/mdx/options.js +7 -4
- package/dist/node/mdx/processor.js +1 -1
- package/dist/node/mdx/rehypePlugins/headerAnchor.js +1 -1
- package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +1 -1
- package/dist/node/mdx/remarkPlugins/image.js +1 -1
- package/dist/node/mdx/remarkPlugins/toc.js +1 -1
- package/dist/node/route/RouteService.js +1 -1
- package/dist/node/route/extractPageData.js +2 -2
- package/dist/node/route/normalizeRoutePath.js +1 -1
- package/dist/node/runtimeModule/i18n.js +1 -1
- package/dist/node/runtimeModule/pageData/createPageData.js +1 -1
- package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
- package/dist/node/runtimeModule/siteData/createSiteData.js +1 -1
- package/dist/node/serve.js +1 -1
- package/dist/node/ssg/renderPage.js +1 -1
- package/dist/node/ssg/renderPageWorker.js +1 -1
- package/dist/node/ssg/renderPages.js +2 -2
- package/dist/node/ssg/ssgEnv.js +1 -1
- package/dist/node/ssg-md/llms/emitLlmsTxt.js +6 -2
- package/dist/node/ssg-md/remarkSplitMdx.js +140 -98
- package/dist/node/ssg-md/renderPage.js +1 -1
- package/dist/node/ssg-md/renderPages.js +1 -1
- package/dist/node/utils/createHash.js +1 -1
- package/dist/node/utils/error.js +2 -1
- package/dist/node/utils/flattenMdxContent.js +2 -2
- package/dist/node/utils/normalizePath.js +1 -1
- package/dist/node/utils/reactAlias.js +1 -1
- package/dist/runtime/initPageData.js +1 -1
- package/dist/theme/assets/deprecated.js +18 -0
- package/dist/theme/assets/experimental.js +21 -0
- package/dist/theme/components/Badge/index.css +1 -0
- package/dist/theme/components/Banner/index.js +2 -2
- package/dist/theme/components/Callout/index.js +5 -2
- package/dist/theme/components/CodeBlock/index.css +7 -6
- package/dist/theme/components/CodeBlock/index.js +4 -1
- package/dist/theme/components/CodeBlockRuntime/index.d.ts +1 -1
- package/dist/theme/components/CodeBlockRuntime/index.js +38 -8
- package/dist/theme/components/DocContent/doc.css +1 -1
- package/dist/theme/components/DocContent/docComponents/pre.js +3 -1
- package/dist/theme/components/DocContent/index.d.ts +11 -2
- package/dist/theme/components/DocContent/index.js +6 -5
- package/dist/theme/components/DocFooter/index.js +1 -5
- package/dist/theme/components/HoverGroup/index.css +3 -3
- package/dist/theme/components/LastUpdated/index.d.ts +1 -1
- package/dist/theme/components/LastUpdated/index.js +5 -1
- package/dist/theme/components/Link/index.d.ts +1 -1
- package/dist/theme/components/Link/index.js +8 -2
- package/dist/theme/components/NavScreen/NavScreenLangs.css +6 -0
- package/dist/theme/components/NavScreen/NavScreenLangs.js +13 -3
- package/dist/theme/components/NavScreen/NavScreenVersions.css +6 -0
- package/dist/theme/components/NavScreen/NavScreenVersions.js +12 -3
- package/dist/theme/components/Overview/index.d.ts +0 -1
- package/dist/theme/components/Overview/index.js +1 -1
- package/dist/theme/components/{Overview/OverviewGroup.css → OverviewGroup/index.css} +60 -8
- package/dist/theme/components/{Overview/OverviewGroup.d.ts → OverviewGroup/index.d.ts} +1 -1
- package/dist/theme/components/OverviewGroup/index.js +88 -0
- package/dist/theme/components/Search/logic/util.test.js +1 -1
- package/dist/theme/components/Tabs/index.css +6 -5
- package/dist/theme/components/Tabs/index.js +9 -0
- package/dist/theme/components/Tag/index.d.ts +3 -0
- package/dist/theme/components/Tag/index.js +63 -8
- package/dist/theme/hooks/useActiveAnchor.js +1 -1
- package/dist/theme/icons.d.ts +26 -24
- package/dist/theme/icons.js +5 -1
- package/dist/theme/index.d.ts +3 -1
- package/dist/theme/index.js +4 -2
- package/dist/theme/layout/DocLayout/index.css +0 -2
- package/dist/theme/layout/Layout/index.js +1 -2
- package/dist/theme/layout/NotFountLayout/index.js +1 -1
- package/dist/theme/logic/useAppearance.js +1 -1
- package/dist/theme/logic/useMediaQuery.js +1 -1
- package/dist/theme/styles/base.css +1 -0
- package/dist/theme/styles/shiki.css +9 -3
- package/dist/theme/styles/vars/base-vars.css +2 -2
- package/dist/theme/styles/vars/code-vars.css +2 -0
- package/package.json +14 -14
- package/dist/1218.3869bad6.js +0 -2
- package/dist/theme/components/Overview/OverviewGroup.js +0 -57
- /package/dist/eject-theme/components/{Overview → OverviewGroup}/icons/plugin.svg +0 -0
- /package/dist/theme/components/{Overview → OverviewGroup}/icons/plugin.js +0 -0
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import * as __rspack_external_child_process from "child_process";
|
|
2
2
|
import * as __rspack_external_fs from "fs";
|
|
3
|
+
import * as __rspack_external_path from "path";
|
|
3
4
|
import * as __rspack_external_stream from "stream";
|
|
4
5
|
import { __webpack_require__ } from "./rslib-runtime.99091bf6.js";
|
|
5
6
|
import { Buffer } from "node:buffer";
|
|
6
7
|
import node_child_process, { ChildProcess } from "node:child_process";
|
|
7
8
|
import { setTimeout as promises_setTimeout } from "node:timers/promises";
|
|
8
9
|
import { debuglog } from "node:util";
|
|
9
|
-
import { node_process } from "./
|
|
10
|
+
import { node_process, node_os, constants } from "./9643.f109822d.js";
|
|
10
11
|
import { node_path } from "./6289.c67fe0d5.js";
|
|
11
|
-
import { node_url } from "./5485.
|
|
12
|
-
import {
|
|
13
|
-
import { createWriteStream, createReadStream, readFileSync } from "./5313.6594aba0.js";
|
|
12
|
+
import { node_url } from "./5485.077f14ff.js";
|
|
13
|
+
import { createWriteStream, createReadStream, readFileSync } from "./3521.56e42d70.js";
|
|
14
14
|
__webpack_require__.add({
|
|
15
|
-
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js" (module,
|
|
15
|
+
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
16
16
|
const cp = __webpack_require__("child_process");
|
|
17
17
|
const parse = __webpack_require__("../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js");
|
|
18
18
|
const enoent = __webpack_require__("../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/enoent.js");
|
|
@@ -71,7 +71,7 @@ __webpack_require__.add({
|
|
|
71
71
|
notFoundError
|
|
72
72
|
};
|
|
73
73
|
},
|
|
74
|
-
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js" (module,
|
|
74
|
+
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
75
75
|
const path = __webpack_require__("path");
|
|
76
76
|
const resolveCommand = __webpack_require__("../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js");
|
|
77
77
|
const escape = __webpack_require__("../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/escape.js");
|
|
@@ -151,7 +151,7 @@ __webpack_require__.add({
|
|
|
151
151
|
module.exports.command = escapeCommand;
|
|
152
152
|
module.exports.argument = escapeArgument;
|
|
153
153
|
},
|
|
154
|
-
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js" (module,
|
|
154
|
+
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
155
155
|
const fs = __webpack_require__("fs");
|
|
156
156
|
const shebangCommand = __webpack_require__("../../node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.js");
|
|
157
157
|
function readShebang(command) {
|
|
@@ -167,7 +167,7 @@ __webpack_require__.add({
|
|
|
167
167
|
}
|
|
168
168
|
module.exports = readShebang;
|
|
169
169
|
},
|
|
170
|
-
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js" (module,
|
|
170
|
+
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
171
171
|
const path = __webpack_require__("path");
|
|
172
172
|
const which = __webpack_require__("../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js");
|
|
173
173
|
const getPathKey = __webpack_require__("../../node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.js");
|
|
@@ -198,7 +198,7 @@ __webpack_require__.add({
|
|
|
198
198
|
}
|
|
199
199
|
module.exports = resolveCommand;
|
|
200
200
|
},
|
|
201
|
-
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js" (module,
|
|
201
|
+
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
202
202
|
__webpack_require__("fs");
|
|
203
203
|
var core;
|
|
204
204
|
core = 'win32' === process.platform || global.TESTING_WINDOWS ? __webpack_require__("../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js") : __webpack_require__("../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js");
|
|
@@ -237,7 +237,7 @@ __webpack_require__.add({
|
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
239
|
},
|
|
240
|
-
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js" (module,
|
|
240
|
+
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
241
241
|
module.exports = isexe;
|
|
242
242
|
isexe.sync = sync;
|
|
243
243
|
var fs = __webpack_require__("fs");
|
|
@@ -266,7 +266,7 @@ __webpack_require__.add({
|
|
|
266
266
|
return ret;
|
|
267
267
|
}
|
|
268
268
|
},
|
|
269
|
-
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js" (module,
|
|
269
|
+
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
270
270
|
module.exports = isexe;
|
|
271
271
|
isexe.sync = sync;
|
|
272
272
|
var fs = __webpack_require__("fs");
|
|
@@ -294,7 +294,7 @@ __webpack_require__.add({
|
|
|
294
294
|
return checkStat(fs.statSync(path), path, options);
|
|
295
295
|
}
|
|
296
296
|
},
|
|
297
|
-
"../../node_modules/.pnpm/merge-stream@2.0.0/node_modules/merge-stream/index.js" (module,
|
|
297
|
+
"../../node_modules/.pnpm/merge-stream@2.0.0/node_modules/merge-stream/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
298
298
|
const { PassThrough } = __webpack_require__("stream");
|
|
299
299
|
module.exports = function() {
|
|
300
300
|
var sources = [];
|
|
@@ -341,7 +341,7 @@ __webpack_require__.add({
|
|
|
341
341
|
module.exports = pathKey;
|
|
342
342
|
module.exports["default"] = pathKey;
|
|
343
343
|
},
|
|
344
|
-
"../../node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.js" (module,
|
|
344
|
+
"../../node_modules/.pnpm/shebang-command@2.0.0/node_modules/shebang-command/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
345
345
|
const shebangRegex = __webpack_require__("../../node_modules/.pnpm/shebang-regex@3.0.0/node_modules/shebang-regex/index.js");
|
|
346
346
|
module.exports = (string = '')=>{
|
|
347
347
|
const match = string.match(shebangRegex);
|
|
@@ -355,7 +355,7 @@ __webpack_require__.add({
|
|
|
355
355
|
"../../node_modules/.pnpm/shebang-regex@3.0.0/node_modules/shebang-regex/index.js" (module) {
|
|
356
356
|
module.exports = /^#!(.*)/;
|
|
357
357
|
},
|
|
358
|
-
"../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js" (module,
|
|
358
|
+
"../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
359
359
|
const isWindows = 'win32' === process.platform || 'cygwin' === process.env.OSTYPE || 'msys' === process.env.OSTYPE;
|
|
360
360
|
const path = __webpack_require__("path");
|
|
361
361
|
const COLON = isWindows ? ';' : ':';
|
|
@@ -448,6 +448,9 @@ __webpack_require__.add({
|
|
|
448
448
|
fs (module) {
|
|
449
449
|
module.exports = __rspack_external_fs;
|
|
450
450
|
},
|
|
451
|
+
path (module) {
|
|
452
|
+
module.exports = __rspack_external_path;
|
|
453
|
+
},
|
|
451
454
|
stream (module) {
|
|
452
455
|
module.exports = __rspack_external_stream;
|
|
453
456
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import * as __rspack_external_path from "path";
|
|
2
|
-
import { __webpack_require__ } from "./rslib-runtime.99091bf6.js";
|
|
3
1
|
import { matchPath } from "react-router-dom";
|
|
4
2
|
import { DEFAULT_CONFIG_EXTENSIONS, DEFAULT_CONFIG_NAME, DEFAULT_PAGE_EXTENSIONS } from "@rspress/shared/constants";
|
|
5
3
|
import { glob } from "tinyglobby";
|
|
@@ -11,11 +9,6 @@ import node_fs, { createReadStream, createWriteStream, readFileSync } from "node
|
|
|
11
9
|
import { mergeRsbuildConfig, rspack as core_rspack } from "@rsbuild/core";
|
|
12
10
|
import { createHash } from "node:crypto";
|
|
13
11
|
import { extname, join } from "./6289.c67fe0d5.js";
|
|
14
|
-
__webpack_require__.add({
|
|
15
|
-
path (module) {
|
|
16
|
-
module.exports = __rspack_external_path;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
12
|
const PLUGIN_VIRTUAL_MODULE_NAME = 'rsbuild:virtual-module';
|
|
20
13
|
const pluginVirtualModule = (pluginOptions = {})=>({
|
|
21
14
|
name: PLUGIN_VIRTUAL_MODULE_NAME,
|
|
@@ -2,7 +2,7 @@ import { createRequire } from "node:module";
|
|
|
2
2
|
import node_url, { fileURLToPath, pathToFileURL } from "node:url";
|
|
3
3
|
import { createHead, transformHtmlTemplate } from "@unhead/react/server";
|
|
4
4
|
var package_namespaceObject = {
|
|
5
|
-
rE: "2.0.0-rc.
|
|
5
|
+
rE: "2.0.0-rc.3"
|
|
6
6
|
};
|
|
7
7
|
async function pMap(iterable, mapper, { concurrency = 1 / 0, stopOnError = true, signal } = {}) {
|
|
8
8
|
return new Promise((resolve_, reject_)=>{
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { extractTextAndId, getIconUrlPath, getNodeAttribute, loadFrontMatter } from "@rspress/shared/node-utils";
|
|
2
2
|
import node_os, { constants } from "node:os";
|
|
3
|
+
import node_process, { cwd } from "node:process";
|
|
3
4
|
import { createProcessor, nodeTypes } from "@mdx-js/mdx";
|
|
4
|
-
export { constants, createProcessor, extractTextAndId, getIconUrlPath, getNodeAttribute, loadFrontMatter, nodeTypes, node_os };
|
|
5
|
+
export { constants, createProcessor, cwd, extractTextAndId, getIconUrlPath, getNodeAttribute, loadFrontMatter, nodeTypes, node_os, node_process };
|
|
@@ -29,11 +29,20 @@ function toMarkdown(root) {
|
|
|
29
29
|
case 'i':
|
|
30
30
|
return `*${childrenMd}*`;
|
|
31
31
|
case 'code':
|
|
32
|
+
if (root.parent?.type === 'pre') return childrenMd;
|
|
32
33
|
return `\`${childrenMd}\``;
|
|
33
34
|
case 'pre':
|
|
34
35
|
{
|
|
35
|
-
const
|
|
36
|
-
|
|
36
|
+
const _language = props['data-lang'] || props.language || props.lang || '';
|
|
37
|
+
const language = 'string' == typeof _language ? _language : '';
|
|
38
|
+
const title = props['data-title'] || '';
|
|
39
|
+
const block = [
|
|
40
|
+
'markdown',
|
|
41
|
+
'mdx',
|
|
42
|
+
'md',
|
|
43
|
+
''
|
|
44
|
+
].includes(language) ? '````' : '```';
|
|
45
|
+
return `\n${block}${language}${title ? ` title=${title}` : ''}\n${childrenMd}\n${block}\n`;
|
|
37
46
|
}
|
|
38
47
|
case 'a':
|
|
39
48
|
return `[${childrenMd}](${props.href || '#'})`;
|
|
@@ -88,8 +97,12 @@ function toMarkdown(root) {
|
|
|
88
97
|
}
|
|
89
98
|
async function renderToMarkdownString(element) {
|
|
90
99
|
const container = new MarkdownNode('root');
|
|
91
|
-
const root = reconciler.createContainer(container, 1, null, false, false, '', (
|
|
92
|
-
if (process.env.DEBUG)
|
|
100
|
+
const root = reconciler.createContainer(container, 1, null, false, false, '', (error, info)=>{
|
|
101
|
+
if (process.env.DEBUG) {
|
|
102
|
+
console.error('Reconciler Error:', error, info);
|
|
103
|
+
const message = 'Reconciler Error:' + error.message;
|
|
104
|
+
throw new Error(message);
|
|
105
|
+
}
|
|
93
106
|
}, ()=>{}, (...args)=>{
|
|
94
107
|
if (process.env.DEBUG) console.log('Reconciler onRecoverable Error:', ...args);
|
|
95
108
|
}, ()=>{}, null);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { node_fs, DEFAULT_CONFIG_EXTENSIONS, DEFAULT_CONFIG_NAME } from "../../
|
|
1
|
+
import { node_fs, DEFAULT_CONFIG_EXTENSIONS, DEFAULT_CONFIG_NAME } from "../../3521.56e42d70.js";
|
|
2
2
|
import { node_path, logger } from "../../6289.c67fe0d5.js";
|
|
3
3
|
const findConfig = (basePath)=>DEFAULT_CONFIG_EXTENSIONS.map((ext)=>basePath + ext).find(node_fs.existsSync);
|
|
4
4
|
async function loadConfigFile(customConfigFile) {
|
package/dist/cli/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { node_path, logger, join, picocolors } from "../6289.c67fe0d5.js";
|
|
2
2
|
import { chokidar, cac } from "./index.cb89dbd1.js";
|
|
3
|
-
import { package_namespaceObject } from "../5485.
|
|
3
|
+
import { package_namespaceObject } from "../5485.077f14ff.js";
|
|
4
4
|
import { loadConfigFile, resolveDocRoot } from "./config/loadConfigFile.js";
|
|
5
5
|
import { dev } from "../node/dev.js";
|
|
6
6
|
import { PUBLIC_DIR } from "../node/constants.js";
|
|
@@ -74,7 +74,9 @@ export const Banner = forwardRef<HTMLDivElement, BannerProps>(
|
|
|
74
74
|
|
|
75
75
|
const [height, setHeight] = useState(36);
|
|
76
76
|
const ref = mergeRefs(forwardedRef, element => {
|
|
77
|
-
|
|
77
|
+
if (element?.offsetHeight) {
|
|
78
|
+
setHeight(element?.offsetHeight);
|
|
79
|
+
}
|
|
78
80
|
});
|
|
79
81
|
const [disable, setDisable] = useState(false);
|
|
80
82
|
|
|
@@ -7,6 +7,10 @@ export interface CalloutProps {
|
|
|
7
7
|
children: ReactNode;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
function capitalize(type: string) {
|
|
11
|
+
return type.charAt(0).toUpperCase() + type.slice(1);
|
|
12
|
+
}
|
|
13
|
+
|
|
10
14
|
/**
|
|
11
15
|
* Construct the DOM structure of the container directive.
|
|
12
16
|
* For example:
|
|
@@ -30,7 +34,9 @@ export function Callout({ type, title, children }: CalloutProps): ReactNode {
|
|
|
30
34
|
if (isDetails) {
|
|
31
35
|
return (
|
|
32
36
|
<details className={`rp-callout rp-callout--${type}`}>
|
|
33
|
-
<summary className="rp-callout__title">
|
|
37
|
+
<summary className="rp-callout__title">
|
|
38
|
+
{title ?? capitalize(type)}
|
|
39
|
+
</summary>
|
|
34
40
|
<div className="rp-callout__content">{children}</div>
|
|
35
41
|
</details>
|
|
36
42
|
);
|
|
@@ -38,7 +44,7 @@ export function Callout({ type, title, children }: CalloutProps): ReactNode {
|
|
|
38
44
|
|
|
39
45
|
return (
|
|
40
46
|
<div className={`rp-callout rp-callout--${type}`}>
|
|
41
|
-
<div className="rp-callout__title">{title}</div>
|
|
47
|
+
<div className="rp-callout__title">{title ?? capitalize(type)}</div>
|
|
42
48
|
<div className="rp-callout__content">{children}</div>
|
|
43
49
|
</div>
|
|
44
50
|
);
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
.rp-codeblock {
|
|
2
2
|
position: relative;
|
|
3
|
-
margin:
|
|
3
|
+
margin: 1rem 0;
|
|
4
4
|
border: var(--rp-code-block-border);
|
|
5
|
+
box-shadow: var(--rp-code-block-shadow);
|
|
6
|
+
|
|
5
7
|
overflow-x: auto;
|
|
6
8
|
transition: none;
|
|
7
9
|
border-radius: var(--rp-radius);
|
|
8
10
|
|
|
9
11
|
@media (max-width: 640px) {
|
|
10
|
-
margin:
|
|
12
|
+
margin: 1.5rem 0;
|
|
11
13
|
contain: content;
|
|
12
14
|
}
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
.rp-codeblock__title {
|
|
16
18
|
font-family: var(--rp-font-family-mono);
|
|
17
|
-
padding:
|
|
19
|
+
padding: 0.75rem 1rem;
|
|
18
20
|
font-size: var(--rp-code-font-size);
|
|
19
21
|
background-color: var(--rp-code-title-bg);
|
|
20
22
|
border-bottom: var(--rp-code-block-border);
|
|
@@ -57,7 +59,7 @@
|
|
|
57
59
|
font-size: var(--rp-code-font-size);
|
|
58
60
|
font-family: var(--rp-font-family-mono);
|
|
59
61
|
display: inline-block;
|
|
60
|
-
padding:
|
|
62
|
+
padding: 1rem 0;
|
|
61
63
|
width: fit-content;
|
|
62
64
|
min-width: 100%;
|
|
63
65
|
line-height: 1.7;
|
|
@@ -74,8 +76,8 @@
|
|
|
74
76
|
& .line::before {
|
|
75
77
|
content: counter(step);
|
|
76
78
|
counter-increment: step;
|
|
77
|
-
width:
|
|
78
|
-
margin-right:
|
|
79
|
+
width: 1rem;
|
|
80
|
+
margin-right: 1rem;
|
|
79
81
|
display: inline-block;
|
|
80
82
|
text-align: right;
|
|
81
83
|
color: rgba(115, 138, 148, 0.4);
|
|
@@ -69,6 +69,10 @@ export function CodeBlock({
|
|
|
69
69
|
codeButtonGroupProps,
|
|
70
70
|
children,
|
|
71
71
|
}: CodeBlockProps) {
|
|
72
|
+
if (process.env.__SSR_MD__) {
|
|
73
|
+
return <>{children}</>;
|
|
74
|
+
}
|
|
75
|
+
|
|
72
76
|
const { codeWrap, toggleCodeWrap, copyElementRef } =
|
|
73
77
|
useCodeButtonGroup(wrapCodeProp);
|
|
74
78
|
return (
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import type { CodeBlockProps } from '@theme';
|
|
2
2
|
import { getCustomMDXComponent } from '@theme';
|
|
3
3
|
import { toJsxRuntime } from 'hast-util-to-jsx-runtime';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
Fragment,
|
|
6
|
+
type ReactNode,
|
|
7
|
+
useEffect,
|
|
8
|
+
useMemo,
|
|
9
|
+
useRef,
|
|
10
|
+
useState,
|
|
11
|
+
} from 'react';
|
|
5
12
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
6
13
|
import {
|
|
7
14
|
type BundledLanguage,
|
|
@@ -47,9 +54,37 @@ export function CodeBlockRuntime({
|
|
|
47
54
|
children: _,
|
|
48
55
|
containerElementClassName,
|
|
49
56
|
onRendered,
|
|
50
|
-
|
|
57
|
+
wrapCode,
|
|
58
|
+
lineNumbers,
|
|
51
59
|
}: CodeBlockRuntimeProps) {
|
|
52
|
-
|
|
60
|
+
// getCustomMDXComponent is stable for theme rendering
|
|
61
|
+
const mdxComponents = useMemo(() => getCustomMDXComponent(), []);
|
|
62
|
+
const { pre: ShikiPre, code: Code, ...otherMdxComponents } = mdxComponents;
|
|
63
|
+
const fallback = useMemo(
|
|
64
|
+
() => (
|
|
65
|
+
<ShikiPre
|
|
66
|
+
title={title}
|
|
67
|
+
lang={lang}
|
|
68
|
+
wrapCode={wrapCode}
|
|
69
|
+
lineNumbers={lineNumbers}
|
|
70
|
+
containerElementClassName={containerElementClassName}
|
|
71
|
+
codeButtonGroupProps={codeButtonGroupProps}
|
|
72
|
+
className="shiki css-variables"
|
|
73
|
+
>
|
|
74
|
+
<Code style={{ padding: '1rem 1.25rem' }}>{code}</Code>
|
|
75
|
+
</ShikiPre>
|
|
76
|
+
),
|
|
77
|
+
[
|
|
78
|
+
title,
|
|
79
|
+
lang,
|
|
80
|
+
wrapCode,
|
|
81
|
+
lineNumbers,
|
|
82
|
+
containerElementClassName,
|
|
83
|
+
codeButtonGroupProps,
|
|
84
|
+
code,
|
|
85
|
+
],
|
|
86
|
+
);
|
|
87
|
+
const [child, setChild] = useState<ReactNode | null>(fallback);
|
|
53
88
|
const codeRef = useLatest(code);
|
|
54
89
|
|
|
55
90
|
useEffect(() => {
|
|
@@ -66,12 +101,6 @@ export function CodeBlockRuntime({
|
|
|
66
101
|
return;
|
|
67
102
|
}
|
|
68
103
|
|
|
69
|
-
const {
|
|
70
|
-
pre: ShikiPre,
|
|
71
|
-
code: Code,
|
|
72
|
-
...otherMdxComponents
|
|
73
|
-
} = getCustomMDXComponent();
|
|
74
|
-
|
|
75
104
|
const reactNode = toJsxRuntime(hast, {
|
|
76
105
|
jsx,
|
|
77
106
|
jsxs,
|
|
@@ -84,8 +113,9 @@ export function CodeBlockRuntime({
|
|
|
84
113
|
lang={lang}
|
|
85
114
|
containerElementClassName={containerElementClassName}
|
|
86
115
|
codeButtonGroupProps={codeButtonGroupProps}
|
|
116
|
+
wrapCode={wrapCode}
|
|
117
|
+
lineNumbers={lineNumbers}
|
|
87
118
|
{...props}
|
|
88
|
-
{...otherProps}
|
|
89
119
|
/>
|
|
90
120
|
),
|
|
91
121
|
code: props => <Code {...props} />,
|
|
@@ -96,7 +126,16 @@ export function CodeBlockRuntime({
|
|
|
96
126
|
setChild(reactNode);
|
|
97
127
|
};
|
|
98
128
|
void highlightCode();
|
|
99
|
-
}, [
|
|
129
|
+
}, [
|
|
130
|
+
code,
|
|
131
|
+
codeButtonGroupProps,
|
|
132
|
+
containerElementClassName,
|
|
133
|
+
lang,
|
|
134
|
+
lineNumbers,
|
|
135
|
+
shikiOptions,
|
|
136
|
+
title,
|
|
137
|
+
wrapCode,
|
|
138
|
+
]);
|
|
100
139
|
|
|
101
140
|
useEffect(() => {
|
|
102
141
|
if (child) {
|
|
@@ -21,7 +21,8 @@ export function ShikiPre({
|
|
|
21
21
|
containerElementClassName={containerElementClassName}
|
|
22
22
|
codeButtonGroupProps={codeButtonGroupProps}
|
|
23
23
|
>
|
|
24
|
-
|
|
24
|
+
{/* data-lang is a meta for SSG-MD */}
|
|
25
|
+
<pre {...otherProps} data-lang={lang} data-title={title} />
|
|
25
26
|
</CodeBlock>
|
|
26
27
|
);
|
|
27
28
|
}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { MDXProvider } from '@mdx-js/react';
|
|
2
2
|
import { Content, usePage, useSite } from '@rspress/core/runtime';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import {
|
|
4
|
+
Callout,
|
|
5
|
+
FallbackHeading,
|
|
6
|
+
getCustomMDXComponent,
|
|
7
|
+
useScrollAfterNav,
|
|
8
|
+
} from '@theme';
|
|
6
9
|
import './doc.scss';
|
|
7
10
|
|
|
8
|
-
|
|
11
|
+
function FallbackTitle() {
|
|
9
12
|
const { site } = useSite();
|
|
10
13
|
const { page } = usePage();
|
|
11
14
|
const { headingTitle, title } = page;
|
|
@@ -19,9 +22,21 @@ export function FallbackTitle() {
|
|
|
19
22
|
export function DocContent({
|
|
20
23
|
components,
|
|
21
24
|
isOverviewPage = false,
|
|
25
|
+
afterDocContent,
|
|
26
|
+
beforeDocContent,
|
|
22
27
|
}: {
|
|
23
28
|
components: Record<string, React.FC<any>> | undefined;
|
|
24
29
|
isOverviewPage?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Optional React node rendered before the main document content.
|
|
32
|
+
* Can be used for banners, notices, or custom elements at the top of the page.
|
|
33
|
+
*/
|
|
34
|
+
beforeDocContent?: React.ReactNode;
|
|
35
|
+
/**
|
|
36
|
+
* Optional React node rendered after the main document content.
|
|
37
|
+
* Can be used for footers, navigation, or other content at the bottom of the page.
|
|
38
|
+
*/
|
|
39
|
+
afterDocContent?: React.ReactNode;
|
|
25
40
|
}) {
|
|
26
41
|
useScrollAfterNav();
|
|
27
42
|
|
|
@@ -35,8 +50,10 @@ export function DocContent({
|
|
|
35
50
|
|
|
36
51
|
return (
|
|
37
52
|
<MDXProvider components={mdxComponents}>
|
|
53
|
+
{beforeDocContent}
|
|
38
54
|
{!isOverviewPage && <FallbackTitle />}
|
|
39
55
|
<Content />
|
|
56
|
+
{afterDocContent}
|
|
40
57
|
</MDXProvider>
|
|
41
58
|
);
|
|
42
59
|
}
|
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
import { useSite } from '@rspress/core/runtime';
|
|
2
1
|
import { EditLink, LastUpdated, PrevNextPage } from '@theme';
|
|
3
2
|
import './index.scss';
|
|
4
3
|
|
|
5
4
|
export function DocFooter() {
|
|
6
|
-
const { site } = useSite();
|
|
7
|
-
const { themeConfig } = site;
|
|
8
|
-
const showLastUpdated = themeConfig.lastUpdated;
|
|
9
|
-
|
|
10
5
|
return (
|
|
11
6
|
<footer className="rp-doc-footer">
|
|
12
7
|
<div className="rp-doc-footer__edit">
|
|
13
8
|
<EditLink />
|
|
14
|
-
|
|
9
|
+
<LastUpdated />
|
|
15
10
|
</div>
|
|
16
11
|
<div className="rp-doc-footer__divider" />
|
|
17
12
|
<PrevNextPage />
|
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
import { useI18n, usePage } from '@rspress/core/runtime';
|
|
1
|
+
import { useI18n, usePage, useSite } from '@rspress/core/runtime';
|
|
2
2
|
import './index.scss';
|
|
3
3
|
|
|
4
4
|
export function LastUpdated() {
|
|
5
5
|
const {
|
|
6
6
|
page: { lastUpdatedTime },
|
|
7
7
|
} = usePage();
|
|
8
|
+
const { site } = useSite();
|
|
9
|
+
const { themeConfig } = site;
|
|
10
|
+
const showLastUpdated = themeConfig.lastUpdated;
|
|
8
11
|
|
|
9
12
|
const t = useI18n();
|
|
10
13
|
|
|
14
|
+
if (!showLastUpdated) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
|
|
11
18
|
return (
|
|
12
19
|
<div className="rp-last-updated">
|
|
13
20
|
<p>
|
|
@@ -3,6 +3,7 @@ import clsx from 'clsx';
|
|
|
3
3
|
import nprogress from 'nprogress';
|
|
4
4
|
import type React from 'react';
|
|
5
5
|
import type { ComponentProps, TransitionStartFunction } from 'react';
|
|
6
|
+
import { forwardRef } from 'react';
|
|
6
7
|
import './index.scss';
|
|
7
8
|
import { getHref, useLinkNavigate } from './useLinkNavigate';
|
|
8
9
|
|
|
@@ -43,7 +44,7 @@ nprogress.configure({ showSpinner: false });
|
|
|
43
44
|
* 3. If inCurrentSite, it will navigate and scroll to anchor, preload the asyncChunk onHover the link
|
|
44
45
|
* 4. Link is styled.
|
|
45
46
|
*/
|
|
46
|
-
export
|
|
47
|
+
export const Link = forwardRef<HTMLAnchorElement, LinkProps>((props, ref) => {
|
|
47
48
|
const {
|
|
48
49
|
href = '/',
|
|
49
50
|
children,
|
|
@@ -60,6 +61,7 @@ export function Link(props: LinkProps) {
|
|
|
60
61
|
if (linkType === 'external') {
|
|
61
62
|
return (
|
|
62
63
|
<a
|
|
64
|
+
ref={ref}
|
|
63
65
|
href={href}
|
|
64
66
|
target="_blank"
|
|
65
67
|
rel="noopener noreferrer"
|
|
@@ -76,6 +78,7 @@ export function Link(props: LinkProps) {
|
|
|
76
78
|
if (linkType === 'hashOnly') {
|
|
77
79
|
return (
|
|
78
80
|
<a
|
|
81
|
+
ref={ref}
|
|
79
82
|
href={href}
|
|
80
83
|
className={clsx(className, 'rp-link')}
|
|
81
84
|
onClick={onClick}
|
|
@@ -90,6 +93,7 @@ export function Link(props: LinkProps) {
|
|
|
90
93
|
if (linkType === 'relative') {
|
|
91
94
|
return (
|
|
92
95
|
<a
|
|
96
|
+
ref={ref}
|
|
93
97
|
href={href}
|
|
94
98
|
className={clsx(className, 'rp-link')}
|
|
95
99
|
onMouseEnter={event => {
|
|
@@ -123,6 +127,7 @@ export function Link(props: LinkProps) {
|
|
|
123
127
|
|
|
124
128
|
return (
|
|
125
129
|
<a
|
|
130
|
+
ref={ref}
|
|
126
131
|
href={withBaseHref}
|
|
127
132
|
className={clsx(className, 'rp-link')}
|
|
128
133
|
onMouseEnter={event => {
|
|
@@ -152,4 +157,6 @@ export function Link(props: LinkProps) {
|
|
|
152
157
|
{children}
|
|
153
158
|
</a>
|
|
154
159
|
);
|
|
155
|
-
}
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
Link.displayName = 'Link';
|
|
@@ -3,6 +3,7 @@ import { useLangsMenu } from '../Nav/hooks';
|
|
|
3
3
|
import './NavScreenLangs.scss';
|
|
4
4
|
import { useI18n } from '@rspress/core/runtime';
|
|
5
5
|
import { Link } from '@theme';
|
|
6
|
+
import clsx from 'clsx';
|
|
6
7
|
import { SvgDown } from './NavScreenMenuItem';
|
|
7
8
|
|
|
8
9
|
export function NavScreenLangs() {
|
|
@@ -30,15 +31,28 @@ export function NavScreenLangs() {
|
|
|
30
31
|
}}
|
|
31
32
|
>
|
|
32
33
|
<div className="rp-nav-screen-langs-group__inner">
|
|
33
|
-
{items.map(item =>
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
34
|
+
{items.map(item => {
|
|
35
|
+
const isActive = item.text === activeValue;
|
|
36
|
+
const className = clsx(
|
|
37
|
+
'rp-nav-screen-langs-group__item',
|
|
38
|
+
isActive && 'rp-nav-screen-langs-group__item--active',
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
return isActive ? (
|
|
42
|
+
<span
|
|
43
|
+
key={item.text}
|
|
44
|
+
className={className}
|
|
45
|
+
aria-current="page"
|
|
46
|
+
aria-disabled={true}
|
|
47
|
+
>
|
|
48
|
+
{item.text}
|
|
49
|
+
</span>
|
|
50
|
+
) : (
|
|
51
|
+
<Link key={item.text} href={item.link} className={className}>
|
|
52
|
+
{item.text}
|
|
53
|
+
</Link>
|
|
54
|
+
);
|
|
55
|
+
})}
|
|
42
56
|
</div>
|
|
43
57
|
</div>
|
|
44
58
|
</>
|