@rspress/core 2.0.2 → 2.0.4
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.6e0caa9f.js → 0~7675.423f6a06.js} +2 -2
- package/dist/{5485.5f8db93a.js → 5485.7e481fde.js} +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/config/loadConfigFile.js +1 -1
- package/dist/eject-theme/components/Badge/index.tsx +1 -1
- package/dist/eject-theme/components/Button/index.tsx +1 -1
- package/dist/eject-theme/components/CodeBlock/index.scss +5 -1
- package/dist/eject-theme/components/DocContent/docComponents/title.tsx +7 -2
- package/dist/eject-theme/components/EditLink/index.scss +10 -8
- package/dist/eject-theme/components/EditLink/index.tsx +13 -4
- package/dist/eject-theme/components/HoverGroup/index.tsx +8 -2
- package/dist/eject-theme/components/Llms/LlmsCopyRow.tsx +51 -0
- package/dist/eject-theme/components/Llms/LlmsOpenRow.scss +10 -0
- package/dist/eject-theme/components/Llms/LlmsOpenRow.tsx +170 -0
- package/dist/eject-theme/components/Nav/NavMenu.tsx +7 -1
- package/dist/eject-theme/components/Nav/hooks.tsx +2 -0
- package/dist/eject-theme/components/NavScreen/NavScreenLangs.tsx +8 -1
- package/dist/eject-theme/components/NavScreen/NavScreenMenuItem.scss +0 -1
- package/dist/eject-theme/components/Outline/ScrollToTop.tsx +12 -34
- package/dist/eject-theme/components/Outline/index.scss +41 -5
- package/dist/eject-theme/components/Outline/index.tsx +19 -2
- package/dist/eject-theme/components/OverviewGroup/index.scss +5 -11
- package/dist/eject-theme/components/PackageManagerTabs/index.tsx +10 -2
- package/dist/eject-theme/components/Search/SearchPanel.tsx +2 -1
- package/dist/eject-theme/components/Search/logic/providers/LocalProvider.ts +1 -1
- package/dist/eject-theme/components/Sidebar/SidebarItem.scss +0 -2
- package/dist/eject-theme/components/SidebarMenu/index.scss +25 -1
- package/dist/eject-theme/components/SidebarMenu/index.tsx +5 -2
- package/dist/eject-theme/components/SourceCode/index.tsx +1 -1
- package/dist/eject-theme/components/SvgWrapper/index.tsx +5 -2
- package/dist/eject-theme/components/Tabs/index.scss +1 -1
- package/dist/eject-theme/components/Tabs/index.tsx +1 -1
- package/dist/eject-theme/components/Tag/index.tsx +2 -0
- package/dist/index.js +1 -1
- package/dist/node/auto-nav-sidebar/index.js +1 -1
- package/dist/node/auto-nav-sidebar/normalize.js +30 -4
- package/dist/node/constants.js +1 -1
- package/dist/node/initRsbuild.js +11 -9
- package/dist/node/last-updated/index.js +1 -1
- package/dist/node/logger/hint.d.ts +0 -3
- package/dist/node/logger/hint.js +8 -4
- package/dist/node/mdx/rehypePlugins/transformers/add-line-numbers.js +3 -2
- package/dist/node/mdx/rehypePlugins/transformers/add-wrap-code.js +4 -3
- package/dist/node/route/RouteService.js +1 -1
- package/dist/node/route/extractPageData.js +23 -2
- package/dist/node/route/normalizeRoutePath.js +1 -1
- package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.d.ts +4 -4
- package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.js +4 -4
- package/dist/node/runtimeModule/i18n.js +1 -1
- package/dist/node/runtimeModule/pageData/createPageData.js +2 -2
- package/dist/node/runtimeModule/pageData/rsbuildPlugin.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-md/llms/emitLlmsTxt.js +1 -1
- package/dist/node/ssg-md/remarkSplitMdx.js +11 -1
- package/dist/node/ssg-md/renderPage.js +4 -3
- package/dist/node/ssg-md/renderPages.js +1 -1
- package/dist/node/utils/createHash.js +1 -1
- package/dist/node/utils/flattenMdxContent.js +1 -1
- package/dist/node/utils/reactAlias.d.ts +1 -0
- package/dist/node/utils/reactAlias.js +34 -2
- package/dist/runtime/ssrMdServerEntry.js +1 -1
- package/dist/theme/assets/copy.js +3 -3
- package/dist/theme/assets/edit.js +18 -0
- package/dist/theme/assets/scroll-to-top.js +36 -0
- package/dist/theme/assets/success.js +3 -2
- package/dist/theme/components/Badge/index.d.ts +1 -2
- package/dist/theme/components/Button/index.d.ts +1 -2
- package/dist/theme/components/CodeBlock/index.css +5 -1
- package/dist/theme/components/DocContent/docComponents/title.js +5 -2
- package/dist/theme/components/EditLink/index.css +2 -2
- package/dist/theme/components/EditLink/index.d.ts +3 -1
- package/dist/theme/components/EditLink/index.js +18 -4
- package/dist/theme/components/HoverGroup/index.js +8 -1
- package/dist/theme/components/Llms/LlmsCopyRow.d.ts +1 -0
- package/dist/theme/components/Llms/LlmsCopyRow.js +50 -0
- package/dist/theme/components/Llms/LlmsOpenRow.css +11 -0
- package/dist/theme/components/Llms/LlmsOpenRow.d.ts +3 -0
- package/dist/theme/components/Llms/LlmsOpenRow.js +168 -0
- package/dist/theme/components/Nav/NavMenu.js +3 -0
- package/dist/theme/components/Nav/hooks.d.ts +2 -0
- package/dist/theme/components/Nav/hooks.js +3 -1
- package/dist/theme/components/NavScreen/NavScreenLangs.js +3 -0
- package/dist/theme/components/NavScreen/NavScreenMenuItem.css +0 -1
- package/dist/theme/components/Outline/ScrollToTop.d.ts +1 -2
- package/dist/theme/components/Outline/ScrollToTop.js +7 -32
- package/dist/theme/components/Outline/index.css +39 -4
- package/dist/theme/components/Outline/index.js +16 -4
- package/dist/theme/components/OverviewGroup/index.css +2 -9
- package/dist/theme/components/PackageManagerTabs/index.js +10 -3
- package/dist/theme/components/Search/SearchPanel.js +1 -1
- package/dist/theme/components/Search/logic/providers/LocalProvider.js +1 -1
- package/dist/theme/components/Sidebar/SidebarItem.css +0 -2
- package/dist/theme/components/SidebarMenu/index.css +25 -1
- package/dist/theme/components/SidebarMenu/index.js +3 -1
- package/dist/theme/components/SourceCode/index.d.ts +1 -2
- package/dist/theme/components/SvgWrapper/index.d.ts +1 -2
- package/dist/theme/components/SvgWrapper/index.js +2 -1
- package/dist/theme/components/Tabs/index.css +1 -1
- package/dist/theme/components/Tabs/index.d.ts +1 -1
- package/dist/theme/components/Tag/index.js +4 -0
- package/dist/theme/icons.d.ts +2 -0
- package/dist/theme/icons.js +5 -1
- package/dist/theme/index.d.ts +8 -5
- package/dist/theme/index.js +4 -1
- package/dist/theme/layout/DocLayout/index.css +3 -3
- package/dist/theme/layout/Layout/index.js +10 -4
- package/dist/theme/styles/base.css +4 -0
- package/nav-json-schema.json +12 -0
- package/package.json +14 -16
- package/dist/_private/react/index.js +0 -2
- package/dist/_private/react/reconciler.js +0 -169
- package/dist/_private/react/render.js +0 -118
- package/dist/eject-theme/components/Outline/ScrollToTop.scss +0 -13
- package/dist/node/ssg-md/react/index.d.ts +0 -1
- package/dist/node/ssg-md/react/reconciler.d.ts +0 -18
- package/dist/node/ssg-md/react/render.d.ts +0 -1
- package/dist/node/ssg-md/react/render.test.d.ts +0 -1
- package/dist/theme/components/Outline/ScrollToTop.css +0 -14
- /package/dist/{2577.421b464f.js → 7744.421b464f.js} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*! For license information please see renderPages.js.LICENSE.txt */
|
|
2
2
|
import { logger, picocolors } from "../../6289.29817fb4.js";
|
|
3
|
-
import { chunk } from "../../
|
|
3
|
+
import { chunk } from "../../7744.421b464f.js";
|
|
4
4
|
import { SSGWorkerThreadTaskSize, getNumberOfThreads, SSGWorkerThreadRecyclerMaxMemory, SSGConcurrency } from "./ssgEnv.js";
|
|
5
|
-
import { pMap } from "../../5485.
|
|
5
|
+
import { pMap } from "../../5485.7e481fde.js";
|
|
6
6
|
import { renderPage } from "./renderPage.js";
|
|
7
7
|
import { hintSSGFailed } from "../logger/hint.js";
|
|
8
8
|
import { renderHtmlTemplate } from "./renderHtmlTemplate.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getSidebarDataGroup } from "../../../9348.1beb3e25.js";
|
|
2
|
-
import { matchPath } from "../../../
|
|
2
|
+
import { matchPath } from "../../../7744.421b464f.js";
|
|
3
3
|
import { generateLlmsTxt, generateLlmsFullTxt } from "./llmsTxt.js";
|
|
4
4
|
async function emitLlmsTxt(config, routeService, emitAsset, mdContents) {
|
|
5
5
|
const base = config.base ?? '/';
|
|
@@ -7,11 +7,15 @@ function remarkSplitMdx(options = {}) {
|
|
|
7
7
|
newChildren.push(...importNodes);
|
|
8
8
|
for (const node of tree.children){
|
|
9
9
|
if ('mdxjsEsm' === node.type) continue;
|
|
10
|
+
if ('mdxFlowExpression' === node.type || 'mdxTextExpression' === node.type) {
|
|
11
|
+
newChildren.push(node);
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
10
14
|
if ('mdxJsxFlowElement' === node.type || 'mdxJsxTextElement' === node.type) {
|
|
11
15
|
newChildren.push(processJsxElement(node, importMap, options));
|
|
12
16
|
continue;
|
|
13
17
|
}
|
|
14
|
-
const hasJsxChildren = node.children?.some((child)=>'mdxJsxFlowElement' === child.type || 'mdxJsxTextElement' === child.type);
|
|
18
|
+
const hasJsxChildren = node.children?.some((child)=>'mdxJsxFlowElement' === child.type || 'mdxJsxTextElement' === child.type || 'mdxFlowExpression' === child.type || 'mdxTextExpression' === child.type);
|
|
15
19
|
if (hasJsxChildren) {
|
|
16
20
|
const processedChildren = processMixedContent(node, node.children || [], importMap, options);
|
|
17
21
|
newChildren.push({
|
|
@@ -45,6 +49,9 @@ function processJsxChildren(node, importMap, options) {
|
|
|
45
49
|
for (const child of node.children)if ('mdxJsxFlowElement' === child.type || 'mdxJsxTextElement' === child.type) {
|
|
46
50
|
flushTextBuffer();
|
|
47
51
|
processedChildren.push(processJsxElement(child, importMap, options));
|
|
52
|
+
} else if ('mdxFlowExpression' === child.type || 'mdxTextExpression' === child.type) {
|
|
53
|
+
flushTextBuffer();
|
|
54
|
+
processedChildren.push(child);
|
|
48
55
|
} else textBuffer.push(child);
|
|
49
56
|
flushTextBuffer();
|
|
50
57
|
return {
|
|
@@ -86,6 +93,9 @@ function processMixedContent(parentNode, children, importMap, options) {
|
|
|
86
93
|
for (const child of children)if ('mdxJsxFlowElement' === child.type || 'mdxJsxTextElement' === child.type) {
|
|
87
94
|
flushTextBuffer();
|
|
88
95
|
result.push(processJsxElement(child, importMap, options));
|
|
96
|
+
} else if ('mdxFlowExpression' === child.type || 'mdxTextExpression' === child.type) {
|
|
97
|
+
flushTextBuffer();
|
|
98
|
+
result.push(child);
|
|
89
99
|
} else if ('text' === child.type) textBuffer.push(child.value || '');
|
|
90
100
|
else {
|
|
91
101
|
const serialized = serializeNodeToMarkdown(child);
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { pathToFileURL, createHead } from "../../5485.
|
|
1
|
+
import { pathToFileURL, createHead } from "../../5485.7e481fde.js";
|
|
2
2
|
import { logger, picocolors } from "../../6289.29817fb4.js";
|
|
3
3
|
import { hintSSGFailed } from "../logger/hint.js";
|
|
4
4
|
async function renderPage(route, ssrBundlePath) {
|
|
5
5
|
let render;
|
|
6
6
|
try {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
let { default: ssrExports } = await import(pathToFileURL(ssrBundlePath).toString());
|
|
8
|
+
if (ssrExports instanceof Promise) ssrExports = await ssrExports;
|
|
9
|
+
render = ssrExports.render;
|
|
9
10
|
} catch (e) {
|
|
10
11
|
if (e instanceof Error) {
|
|
11
12
|
logger.error(`Failed to load SSG bundle: ${picocolors.yellow(ssrBundlePath)}: ${e.message}`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { logger, picocolors } from "../../6289.29817fb4.js";
|
|
2
|
-
import { pMap } from "../../5485.
|
|
2
|
+
import { pMap } from "../../5485.7e481fde.js";
|
|
3
3
|
import { renderPage } from "./renderPage.js";
|
|
4
4
|
import { SSGConcurrency } from "../ssg/ssgEnv.js";
|
|
5
5
|
const routePage2MdFilename = (routePath)=>{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createHash as external_node_crypto_createHash } from "../../
|
|
1
|
+
import { createHash as external_node_crypto_createHash } from "../../7744.421b464f.js";
|
|
2
2
|
function createHash(str) {
|
|
3
3
|
return external_node_crypto_createHash('sha256').update(str).digest('hex').slice(0, 8);
|
|
4
4
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { node_fs, core_rspack } from "../../
|
|
1
|
+
import { node_fs, core_rspack } from "../../7744.421b464f.js";
|
|
2
2
|
import { node_path, logger } from "../../6289.29817fb4.js";
|
|
3
3
|
import { createProcessor, MDX_OR_MD_REGEXP } from "../../9348.1beb3e25.js";
|
|
4
4
|
import { createError } from "./error.js";
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export declare function resolveReactRouterDomAlias(): Promise<Record<string, string>>;
|
|
2
2
|
export declare function resolveReactAlias(isSSR: boolean): Promise<Record<string, string>>;
|
|
3
|
+
export declare function resolveReactRenderToMarkdownAlias(): Promise<Record<string, string>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { node_path, logger, picocolors } from "../../6289.29817fb4.js";
|
|
2
|
-
import { core_rspack } from "../../
|
|
2
|
+
import { core_rspack } from "../../7744.421b464f.js";
|
|
3
3
|
import { pathExists, readJson } from "./fs.js";
|
|
4
4
|
import { PACKAGE_ROOT } from "../constants.js";
|
|
5
5
|
import { hintReactVersion } from "../logger/hint.js";
|
|
@@ -80,4 +80,36 @@ async function resolveReactAlias(isSSR) {
|
|
|
80
80
|
}));
|
|
81
81
|
return alias;
|
|
82
82
|
}
|
|
83
|
-
|
|
83
|
+
async function resolveReactRenderToMarkdownAlias() {
|
|
84
|
+
const hasInstalled = await detectPackageMajorVersion('react-render-to-markdown');
|
|
85
|
+
if (!hasInstalled) {
|
|
86
|
+
const reactMajorVersion = await detectPackageMajorVersion('react');
|
|
87
|
+
if (reactMajorVersion && reactMajorVersion < 19) logger.warn(`You are using React ${reactMajorVersion} with \`llms: true\`. Please install \`react-render-to-markdown\` to ensure compatibility.\n\nAdd the following to your ${picocolors.greenBright('package.json')}:\n\n` + picocolors.greenBright(` "dependencies": {\n "react": "^18.3.1",\n "react-dom": "^18.3.1",\n "react-render-to-markdown": "^18.3.1"\n }\n`));
|
|
88
|
+
return {};
|
|
89
|
+
}
|
|
90
|
+
const alias = {};
|
|
91
|
+
const resolver = new Resolver({
|
|
92
|
+
extensions: [
|
|
93
|
+
'.js'
|
|
94
|
+
],
|
|
95
|
+
alias,
|
|
96
|
+
conditionNames: [
|
|
97
|
+
'import',
|
|
98
|
+
'require',
|
|
99
|
+
'node',
|
|
100
|
+
'default'
|
|
101
|
+
]
|
|
102
|
+
});
|
|
103
|
+
try {
|
|
104
|
+
const resolved = await resolver.async(process.cwd(), 'react-render-to-markdown');
|
|
105
|
+
if (resolved.error) throw Error(resolved.error);
|
|
106
|
+
if (!resolved.path) throw Error("'react-render-to-markdown' resolved to empty path");
|
|
107
|
+
return {
|
|
108
|
+
'react-render-to-markdown': resolved.path
|
|
109
|
+
};
|
|
110
|
+
} catch (e) {
|
|
111
|
+
logger.warn('react-render-to-markdown not found: \n', e);
|
|
112
|
+
}
|
|
113
|
+
return {};
|
|
114
|
+
}
|
|
115
|
+
export { resolveReactAlias, resolveReactRenderToMarkdownAlias, resolveReactRouterDomAlias };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { renderToMarkdownString } from "@rspress/core/_private/react";
|
|
3
2
|
import { PageContext, ThemeContext, pathnameToRouteService, removeTrailingSlash, withBase } from "@rspress/core/runtime";
|
|
4
3
|
import { UnheadProvider } from "@unhead/react/server";
|
|
4
|
+
import { renderToMarkdownString } from "react-render-to-markdown";
|
|
5
5
|
import { StaticRouter } from "react-router-dom";
|
|
6
6
|
import { App } from "./App.js";
|
|
7
7
|
import { initPageData } from "./initPageData.js";
|
|
@@ -4,16 +4,16 @@ const SvgCopy = (props)=>/*#__PURE__*/ jsxs("svg", {
|
|
|
4
4
|
xmlns: "http://www.w3.org/2000/svg",
|
|
5
5
|
width: 32,
|
|
6
6
|
height: 32,
|
|
7
|
-
viewBox: "0 0
|
|
7
|
+
viewBox: "0 0 24 24",
|
|
8
8
|
...props,
|
|
9
9
|
children: [
|
|
10
10
|
/*#__PURE__*/ jsx("path", {
|
|
11
11
|
fill: "currentColor",
|
|
12
|
-
d: "
|
|
12
|
+
d: "M20 8v12H8V8zm0-2H8a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2"
|
|
13
13
|
}),
|
|
14
14
|
/*#__PURE__*/ jsx("path", {
|
|
15
15
|
fill: "currentColor",
|
|
16
|
-
d: "M4
|
|
16
|
+
d: "M4 16H2V4a2 2 0 0 1 2-2h12v2H4Z"
|
|
17
17
|
})
|
|
18
18
|
]
|
|
19
19
|
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
const SvgEdit = (props)=>/*#__PURE__*/ jsx("svg", {
|
|
4
|
+
width: "1em",
|
|
5
|
+
height: "1em",
|
|
6
|
+
fill: "none",
|
|
7
|
+
stroke: "currentColor",
|
|
8
|
+
strokeLinecap: "round",
|
|
9
|
+
strokeLinejoin: "round",
|
|
10
|
+
strokeWidth: 2,
|
|
11
|
+
viewBox: "0 0 24 24",
|
|
12
|
+
...props,
|
|
13
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
14
|
+
d: "M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5z"
|
|
15
|
+
})
|
|
16
|
+
});
|
|
17
|
+
var edit = SvgEdit;
|
|
18
|
+
export { edit as default };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
const SvgScrollToTop = (props)=>/*#__PURE__*/ jsxs("svg", {
|
|
4
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5
|
+
width: "1em",
|
|
6
|
+
height: "1em",
|
|
7
|
+
fill: "none",
|
|
8
|
+
viewBox: "0 0 16 16",
|
|
9
|
+
...props,
|
|
10
|
+
children: [
|
|
11
|
+
/*#__PURE__*/ jsx("path", {
|
|
12
|
+
stroke: "currentColor",
|
|
13
|
+
strokeOpacity: 0.8,
|
|
14
|
+
strokeWidth: 1.333,
|
|
15
|
+
d: "M8 14.667A6.667 6.667 0 1 0 8 1.333a6.667 6.667 0 0 0 0 13.334Z",
|
|
16
|
+
clipRule: "evenodd"
|
|
17
|
+
}),
|
|
18
|
+
/*#__PURE__*/ jsx("path", {
|
|
19
|
+
stroke: "currentColor",
|
|
20
|
+
strokeLinejoin: "round",
|
|
21
|
+
strokeOpacity: 0.8,
|
|
22
|
+
strokeWidth: 1.333,
|
|
23
|
+
d: "M8 14.667A6.667 6.667 0 1 0 8 1.333a6.667 6.667 0 0 0 0 13.334Z"
|
|
24
|
+
}),
|
|
25
|
+
/*#__PURE__*/ jsx("path", {
|
|
26
|
+
stroke: "currentColor",
|
|
27
|
+
strokeLinecap: "round",
|
|
28
|
+
strokeLinejoin: "round",
|
|
29
|
+
strokeOpacity: 0.8,
|
|
30
|
+
strokeWidth: 1.333,
|
|
31
|
+
d: "M11 9 8 6 5 9"
|
|
32
|
+
})
|
|
33
|
+
]
|
|
34
|
+
});
|
|
35
|
+
var scroll_to_top = SvgScrollToTop;
|
|
36
|
+
export { scroll_to_top as default };
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
3
|
const SvgSuccess = (props)=>/*#__PURE__*/ jsx("svg", {
|
|
4
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
4
5
|
width: 32,
|
|
5
6
|
height: 32,
|
|
6
|
-
viewBox: "0 0
|
|
7
|
+
viewBox: "0 0 24 24",
|
|
7
8
|
...props,
|
|
8
9
|
children: /*#__PURE__*/ jsx("path", {
|
|
9
10
|
fill: "#49cd37",
|
|
10
|
-
d: "
|
|
11
|
+
d: "m9.55 18-5.7-5.7 1.425-1.425L9.55 15.15l9.175-9.175L20.15 7.4z"
|
|
11
12
|
})
|
|
12
13
|
});
|
|
13
14
|
var success = SvgSuccess;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import './index.scss';
|
|
2
|
-
interface BadgeProps {
|
|
2
|
+
export interface BadgeProps {
|
|
3
3
|
/**
|
|
4
4
|
* The content to display inside the badge. Can be a string or React nodes.
|
|
5
5
|
*/
|
|
@@ -41,4 +41,3 @@ interface BadgeProps {
|
|
|
41
41
|
* <Badge text="Deprecated" type="danger" />
|
|
42
42
|
*/
|
|
43
43
|
export declare function Badge({ children, type, text, outline, }: BadgeProps): import("react/jsx-runtime").JSX.Element;
|
|
44
|
-
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { type JSX } from 'react';
|
|
2
2
|
import './index.scss';
|
|
3
|
-
interface ButtonProps {
|
|
3
|
+
export interface ButtonProps {
|
|
4
4
|
type?: string;
|
|
5
5
|
size?: 'medium' | 'big';
|
|
6
6
|
theme?: 'brand' | 'alt';
|
|
@@ -12,4 +12,3 @@ interface ButtonProps {
|
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
export declare function Button(props: ButtonProps): JSX.Element;
|
|
15
|
-
export {};
|
|
@@ -73,8 +73,12 @@
|
|
|
73
73
|
counter-increment: step;
|
|
74
74
|
text-align: right;
|
|
75
75
|
color: #738a9466;
|
|
76
|
-
width:
|
|
76
|
+
width: 2ch;
|
|
77
77
|
margin-right: 1rem;
|
|
78
78
|
display: inline-block;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
.rp-codeblock__content--line-numbers code:has(.line:nth-child(100)) .line:before {
|
|
82
|
+
width: 3ch;
|
|
83
|
+
}
|
|
84
|
+
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useFrontmatter } from "@rspress/core/runtime";
|
|
2
|
+
import { useFrontmatter, useSite } from "@rspress/core/runtime";
|
|
3
3
|
import { LlmsContainer, LlmsCopyButton, LlmsViewOptions, Tag } from "@theme";
|
|
4
4
|
import clsx from "clsx";
|
|
5
5
|
const H1 = (props)=>{
|
|
6
6
|
const { className, children, ...rest } = props;
|
|
7
7
|
const { frontmatter: { tag } } = useFrontmatter();
|
|
8
|
+
const { site } = useSite();
|
|
9
|
+
const llmsUI = site?.themeConfig?.llmsUI;
|
|
10
|
+
const placement = 'object' == typeof llmsUI ? llmsUI?.placement ?? 'title' : 'title';
|
|
8
11
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
9
12
|
children: [
|
|
10
13
|
/*#__PURE__*/ jsxs("h1", {
|
|
@@ -18,7 +21,7 @@ const H1 = (props)=>{
|
|
|
18
21
|
})
|
|
19
22
|
]
|
|
20
23
|
}),
|
|
21
|
-
process.env.ENABLE_LLMS_UI && /*#__PURE__*/ jsxs(LlmsContainer, {
|
|
24
|
+
process.env.ENABLE_LLMS_UI && 'title' === placement && /*#__PURE__*/ jsxs(LlmsContainer, {
|
|
22
25
|
children: [
|
|
23
26
|
/*#__PURE__*/ jsx(LlmsCopyButton, {}),
|
|
24
27
|
/*#__PURE__*/ jsx(LlmsViewOptions, {})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
.rp-edit-link {
|
|
1
|
+
.rp-doc-footer .rp-edit-link {
|
|
2
2
|
color: var(--rp-c-brand);
|
|
3
3
|
font-size: 15px;
|
|
4
4
|
font-weight: 500;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
transition: all .2s ease-in-out;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
.rp-edit-link:hover {
|
|
9
|
+
.rp-doc-footer .rp-edit-link:hover {
|
|
10
10
|
color: var(--rp-c-brand-dark);
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -1,13 +1,27 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { IconEdit, Link, SvgWrapper } from "@theme";
|
|
2
3
|
import "./index.css";
|
|
3
4
|
import { useEditLink } from "./useEditLink.js";
|
|
4
|
-
function EditLink() {
|
|
5
|
+
function EditLink({ isOutline }) {
|
|
5
6
|
const editLinkObj = useEditLink();
|
|
6
7
|
if (!editLinkObj) return null;
|
|
7
8
|
const { text, link } = editLinkObj;
|
|
8
|
-
return /*#__PURE__*/
|
|
9
|
+
if (isOutline) return /*#__PURE__*/ jsxs(Link, {
|
|
10
|
+
href: link,
|
|
11
|
+
className: "rp-outline__action-row rp-edit-link",
|
|
12
|
+
children: [
|
|
13
|
+
/*#__PURE__*/ jsx(SvgWrapper, {
|
|
14
|
+
icon: IconEdit,
|
|
15
|
+
width: "16",
|
|
16
|
+
height: "16"
|
|
17
|
+
}),
|
|
18
|
+
/*#__PURE__*/ jsx("span", {
|
|
19
|
+
children: text
|
|
20
|
+
})
|
|
21
|
+
]
|
|
22
|
+
});
|
|
23
|
+
return /*#__PURE__*/ jsx(Link, {
|
|
9
24
|
href: link,
|
|
10
|
-
target: "_blank",
|
|
11
25
|
className: "rp-edit-link",
|
|
12
26
|
children: text
|
|
13
27
|
});
|
|
@@ -19,6 +19,9 @@ function HoverGroupItem({ item, activeMatcher, depth = 0 }) {
|
|
|
19
19
|
href: item.link,
|
|
20
20
|
"aria-label": item.text,
|
|
21
21
|
className: "rp-hover-group__item__link",
|
|
22
|
+
lang: item.lang,
|
|
23
|
+
hrefLang: item.lang,
|
|
24
|
+
rel: item.rel,
|
|
22
25
|
children: [
|
|
23
26
|
item.text,
|
|
24
27
|
'tag' in item && item.tag && /*#__PURE__*/ jsx(Tag, {
|
|
@@ -36,7 +39,7 @@ function HoverGroupItem({ item, activeMatcher, depth = 0 }) {
|
|
|
36
39
|
});
|
|
37
40
|
}
|
|
38
41
|
if ('link' in item) {
|
|
39
|
-
const { text, link } = item;
|
|
42
|
+
const { text, link, lang, rel } = item;
|
|
40
43
|
const isActiveItem = activeMatcher ? activeMatcher(item) : matchNavbar(item, pathname);
|
|
41
44
|
return /*#__PURE__*/ jsx("li", {
|
|
42
45
|
className: clsx('rp-hover-group__item', {
|
|
@@ -50,6 +53,9 @@ function HoverGroupItem({ item, activeMatcher, depth = 0 }) {
|
|
|
50
53
|
href: link,
|
|
51
54
|
"aria-label": text,
|
|
52
55
|
className: "rp-hover-group__item__link",
|
|
56
|
+
lang: lang,
|
|
57
|
+
hrefLang: lang,
|
|
58
|
+
rel: rel,
|
|
53
59
|
children: [
|
|
54
60
|
text,
|
|
55
61
|
'tag' in item && item.tag && /*#__PURE__*/ jsx(Tag, {
|
|
@@ -58,6 +64,7 @@ function HoverGroupItem({ item, activeMatcher, depth = 0 }) {
|
|
|
58
64
|
]
|
|
59
65
|
}) : /*#__PURE__*/ jsxs("div", {
|
|
60
66
|
className: "rp-hover-group__item__link",
|
|
67
|
+
lang: lang,
|
|
61
68
|
children: [
|
|
62
69
|
text,
|
|
63
70
|
'tag' in item && item.tag && /*#__PURE__*/ jsx(Tag, {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function LlmsCopyRow(): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useI18n } from "@rspress/core/runtime";
|
|
3
|
+
import { IconCopy, IconSuccess, SvgWrapper } from "@theme";
|
|
4
|
+
import { useCallback, useRef, useState } from "react";
|
|
5
|
+
import { useMdUrl } from "./useMdUrl.js";
|
|
6
|
+
const cache = new Map();
|
|
7
|
+
function LlmsCopyRow() {
|
|
8
|
+
const t = useI18n();
|
|
9
|
+
const { pathname } = useMdUrl();
|
|
10
|
+
const [isLoading, setLoading] = useState(false);
|
|
11
|
+
const [isFinished, setFinished] = useState(false);
|
|
12
|
+
const timer = useRef(null);
|
|
13
|
+
const handleClick = useCallback(async ()=>{
|
|
14
|
+
if (!pathname) return;
|
|
15
|
+
setLoading(true);
|
|
16
|
+
try {
|
|
17
|
+
const content = cache.get(pathname) ?? await fetch(pathname).then((res)=>res.text());
|
|
18
|
+
cache.set(pathname, content);
|
|
19
|
+
await navigator.clipboard.writeText(content);
|
|
20
|
+
} finally{
|
|
21
|
+
setLoading(false);
|
|
22
|
+
setFinished(true);
|
|
23
|
+
if (timer.current) {
|
|
24
|
+
clearTimeout(timer.current);
|
|
25
|
+
timer.current = null;
|
|
26
|
+
}
|
|
27
|
+
timer.current = window.setTimeout(()=>{
|
|
28
|
+
setFinished(false);
|
|
29
|
+
timer.current = null;
|
|
30
|
+
}, 1500);
|
|
31
|
+
}
|
|
32
|
+
}, [
|
|
33
|
+
pathname
|
|
34
|
+
]);
|
|
35
|
+
if (!pathname) return null;
|
|
36
|
+
return /*#__PURE__*/ jsxs("button", {
|
|
37
|
+
className: "rp-outline__action-row",
|
|
38
|
+
onClick: handleClick,
|
|
39
|
+
disabled: isLoading,
|
|
40
|
+
children: [
|
|
41
|
+
/*#__PURE__*/ jsx(SvgWrapper, {
|
|
42
|
+
icon: isFinished ? IconSuccess : IconCopy
|
|
43
|
+
}),
|
|
44
|
+
/*#__PURE__*/ jsx("span", {
|
|
45
|
+
children: t('copyMarkdownText')
|
|
46
|
+
})
|
|
47
|
+
]
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
export { LlmsCopyRow };
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useI18n, useSite } from "@rspress/core/runtime";
|
|
3
|
+
import { IconExternalLink, SvgWrapper } from "@theme";
|
|
4
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
5
|
+
import "./LlmsOpenRow.css";
|
|
6
|
+
import "./LlmsViewOptions.css";
|
|
7
|
+
import { useMdUrl } from "./useMdUrl.js";
|
|
8
|
+
function LlmsOpenRow() {
|
|
9
|
+
const t = useI18n();
|
|
10
|
+
const { pathname } = useMdUrl();
|
|
11
|
+
const { site } = useSite();
|
|
12
|
+
const llmsUI = site?.themeConfig?.llmsUI;
|
|
13
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
14
|
+
const containerRef = useRef(null);
|
|
15
|
+
const options = 'object' == typeof llmsUI && llmsUI?.viewOptions ? llmsUI.viewOptions : [
|
|
16
|
+
'chatgpt',
|
|
17
|
+
'claude'
|
|
18
|
+
];
|
|
19
|
+
useEffect(()=>{
|
|
20
|
+
const handleClickOutside = (event)=>{
|
|
21
|
+
if (containerRef.current && event.target && !containerRef.current.contains(event.target)) setIsOpen(false);
|
|
22
|
+
};
|
|
23
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
24
|
+
return ()=>{
|
|
25
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
26
|
+
};
|
|
27
|
+
}, []);
|
|
28
|
+
const fullMarkdownUrl = useMemo(()=>"u" > typeof window ? new URL(pathname, window.location.origin).toString() : '', [
|
|
29
|
+
pathname
|
|
30
|
+
]);
|
|
31
|
+
const q = `Read ${fullMarkdownUrl}, I want to ask questions about it.`;
|
|
32
|
+
const builtinItems = useMemo(()=>({
|
|
33
|
+
chatgpt: {
|
|
34
|
+
title: t('openInText', {
|
|
35
|
+
name: 'ChatGPT'
|
|
36
|
+
}),
|
|
37
|
+
href: `https://chatgpt.com/?${new URLSearchParams({
|
|
38
|
+
hints: 'search',
|
|
39
|
+
q
|
|
40
|
+
})}`,
|
|
41
|
+
icon: /*#__PURE__*/ jsx("svg", {
|
|
42
|
+
role: "img",
|
|
43
|
+
viewBox: "0 0 24 24",
|
|
44
|
+
fill: "currentColor",
|
|
45
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
46
|
+
width: "16",
|
|
47
|
+
height: "16",
|
|
48
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
49
|
+
d: "M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z"
|
|
50
|
+
})
|
|
51
|
+
})
|
|
52
|
+
},
|
|
53
|
+
claude: {
|
|
54
|
+
title: t('openInText', {
|
|
55
|
+
name: 'Claude'
|
|
56
|
+
}),
|
|
57
|
+
href: `https://claude.ai/new?${new URLSearchParams({
|
|
58
|
+
q
|
|
59
|
+
})}`,
|
|
60
|
+
icon: /*#__PURE__*/ jsx("svg", {
|
|
61
|
+
fill: "currentColor",
|
|
62
|
+
role: "img",
|
|
63
|
+
viewBox: "0 0 24 24",
|
|
64
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
65
|
+
width: "16",
|
|
66
|
+
height: "16",
|
|
67
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
68
|
+
d: "M17.3041 3.541h-3.6718l6.696 16.918H24Zm-10.6082 0L0 20.459h3.7442l1.3693-3.5527h7.0052l1.3693 3.5528h3.7442L10.5363 3.5409Zm-.3712 10.2232 2.2914-5.9456 2.2914 5.9456Z"
|
|
69
|
+
})
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
}), [
|
|
73
|
+
t,
|
|
74
|
+
q
|
|
75
|
+
]);
|
|
76
|
+
if (!pathname) return null;
|
|
77
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
78
|
+
ref: containerRef,
|
|
79
|
+
className: "rp-outline__open-in-wrapper",
|
|
80
|
+
children: [
|
|
81
|
+
/*#__PURE__*/ jsxs("button", {
|
|
82
|
+
className: "rp-outline__action-row",
|
|
83
|
+
onClick: ()=>setIsOpen(!isOpen),
|
|
84
|
+
children: [
|
|
85
|
+
/*#__PURE__*/ jsxs("svg", {
|
|
86
|
+
width: "16",
|
|
87
|
+
height: "16",
|
|
88
|
+
viewBox: "0 0 24 24",
|
|
89
|
+
fill: "none",
|
|
90
|
+
stroke: "currentColor",
|
|
91
|
+
strokeWidth: "2",
|
|
92
|
+
strokeLinecap: "round",
|
|
93
|
+
strokeLinejoin: "round",
|
|
94
|
+
children: [
|
|
95
|
+
/*#__PURE__*/ jsx("path", {
|
|
96
|
+
d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"
|
|
97
|
+
}),
|
|
98
|
+
/*#__PURE__*/ jsx("polyline", {
|
|
99
|
+
points: "15 3 21 3 21 9"
|
|
100
|
+
}),
|
|
101
|
+
/*#__PURE__*/ jsx("line", {
|
|
102
|
+
x1: "10",
|
|
103
|
+
y1: "14",
|
|
104
|
+
x2: "21",
|
|
105
|
+
y2: "3"
|
|
106
|
+
})
|
|
107
|
+
]
|
|
108
|
+
}),
|
|
109
|
+
/*#__PURE__*/ jsx("span", {
|
|
110
|
+
children: t('openInText', {
|
|
111
|
+
name: 'chat'
|
|
112
|
+
})
|
|
113
|
+
})
|
|
114
|
+
]
|
|
115
|
+
}),
|
|
116
|
+
isOpen && /*#__PURE__*/ jsx("div", {
|
|
117
|
+
className: "rp-llms-view-options__menu",
|
|
118
|
+
children: options.map((option)=>{
|
|
119
|
+
let item;
|
|
120
|
+
if ('string' == typeof option && builtinItems[option]) item = builtinItems[option];
|
|
121
|
+
else {
|
|
122
|
+
if ('object' != typeof option || !('title' in option)) return null;
|
|
123
|
+
item = option;
|
|
124
|
+
}
|
|
125
|
+
if (item.href) return /*#__PURE__*/ jsxs("a", {
|
|
126
|
+
className: "rp-llms-view-options__menu-item",
|
|
127
|
+
href: item.href,
|
|
128
|
+
target: "_blank",
|
|
129
|
+
rel: "noopener noreferrer",
|
|
130
|
+
onClick: ()=>setIsOpen(false),
|
|
131
|
+
children: [
|
|
132
|
+
/*#__PURE__*/ jsx("span", {
|
|
133
|
+
className: "rp-llms-view-options__item-icon",
|
|
134
|
+
children: item.icon
|
|
135
|
+
}),
|
|
136
|
+
/*#__PURE__*/ jsx("span", {
|
|
137
|
+
children: item.title
|
|
138
|
+
}),
|
|
139
|
+
/*#__PURE__*/ jsx("span", {
|
|
140
|
+
className: "rp-llms-view-options__external-icon",
|
|
141
|
+
children: /*#__PURE__*/ jsx(SvgWrapper, {
|
|
142
|
+
icon: IconExternalLink
|
|
143
|
+
})
|
|
144
|
+
})
|
|
145
|
+
]
|
|
146
|
+
}, item.title);
|
|
147
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
148
|
+
className: "rp-llms-view-options__menu-item",
|
|
149
|
+
onClick: ()=>{
|
|
150
|
+
item.onClick?.();
|
|
151
|
+
setIsOpen(false);
|
|
152
|
+
},
|
|
153
|
+
children: [
|
|
154
|
+
/*#__PURE__*/ jsx("span", {
|
|
155
|
+
className: "rp-llms-view-options__item-icon",
|
|
156
|
+
children: item.icon
|
|
157
|
+
}),
|
|
158
|
+
/*#__PURE__*/ jsx("span", {
|
|
159
|
+
children: item.title
|
|
160
|
+
})
|
|
161
|
+
]
|
|
162
|
+
}, item.title);
|
|
163
|
+
})
|
|
164
|
+
})
|
|
165
|
+
]
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
export { LlmsOpenRow };
|