@rspress/core 2.0.18 → 2.0.20
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/2711~0.js +3007 -0
- package/dist/{4538.js → 4538~0.js} +1 -1
- package/dist/{5357.js → 5357~0.js} +1 -1
- package/dist/{3553.js → 8472~0.js} +3 -3
- package/dist/{0~execa.js → 864~0.js} +11 -11
- package/dist/cli/index.js +13 -40
- package/dist/config/defineConfig.d.ts +15 -15
- package/dist/config/loadConfigFile.js +2 -3
- package/dist/eject-theme/components/HoverGroup/index.scss +16 -0
- package/dist/eject-theme/components/HoverGroup/index.tsx +22 -1
- package/dist/eject-theme/components/Llms/LlmsCopyButton.tsx +2 -6
- package/dist/eject-theme/components/Llms/LlmsCopyRow.tsx +2 -5
- package/dist/eject-theme/components/Llms/LlmsHint.test.tsx +104 -0
- package/dist/eject-theme/components/Llms/LlmsHint.tsx +74 -0
- package/dist/eject-theme/components/Llms/getLlmsCopyContent.test.ts +21 -0
- package/dist/eject-theme/components/Llms/getLlmsCopyContent.ts +20 -0
- package/dist/eject-theme/components/Llms/index.tsx +1 -1
- package/dist/eject-theme/components/Nav/NavMenu.scss +16 -0
- package/dist/eject-theme/components/Nav/NavMenu.tsx +12 -0
- package/dist/eject-theme/components/Nav/hooks.tsx +1 -2
- package/dist/eject-theme/components/NavScreen/NavScreenMenuItem.scss +18 -2
- package/dist/eject-theme/components/NavScreen/NavScreenMenuItem.tsx +27 -19
- package/dist/eject-theme/components/NavScreen/index.scss +4 -0
- package/dist/eject-theme/components/Outline/index.scss +4 -0
- package/dist/eject-theme/components/Search/logic/providers/LocalProvider.ts +1 -1
- package/dist/eject-theme/components/Sidebar/SidebarGroup.tsx +3 -0
- package/dist/eject-theme/components/Sidebar/SidebarItem.scss +16 -0
- package/dist/eject-theme/components/Sidebar/SidebarItem.test.tsx +51 -0
- package/dist/eject-theme/components/Sidebar/SidebarItem.tsx +10 -1
- package/dist/eject-theme/components/Sidebar/SidebarSectionHeader.scss +15 -0
- package/dist/eject-theme/components/Sidebar/SidebarSectionHeader.tsx +6 -1
- package/dist/eject-theme/components/Sidebar/index.tsx +1 -0
- package/dist/index.js +1 -1
- package/dist/node/PluginDriver.js +1 -1
- package/dist/node/auto-nav-sidebar/index.js +1 -1
- package/dist/node/auto-nav-sidebar/locales.js +1 -1
- package/dist/node/auto-nav-sidebar/normalize.js +40 -12
- package/dist/node/auto-nav-sidebar/type.d.ts +7 -0
- package/dist/node/auto-nav-sidebar/utils.d.ts +1 -0
- package/dist/node/auto-nav-sidebar/utils.js +2 -1
- package/dist/node/auto-nav-sidebar/walk.js +1 -1
- package/dist/node/constants.d.ts +2 -1
- package/dist/node/constants.js +50 -2
- package/dist/node/dev.d.ts +2 -1
- package/dist/node/dev.js +7 -2
- package/dist/node/eject.js +3 -3
- package/dist/node/initRsbuild.d.ts +6 -2
- package/dist/node/initRsbuild.js +37 -13
- package/dist/node/last-updated/index.js +113 -16
- package/dist/node/logger/hint.js +2 -2
- package/dist/node/mdx/options.js +3 -2
- package/dist/node/mdx/processor.js +1 -1
- package/dist/node/mdx/rehypePlugins/codeMeta.js +1 -1
- package/dist/node/mdx/rehypePlugins/headerAnchor.js +1 -1
- package/dist/node/mdx/rehypePlugins/shiki.js +1 -1
- package/dist/node/mdx/remarkPlugins/builtin.js +1 -1
- package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +3 -3
- package/dist/node/mdx/remarkPlugins/image.js +3 -3
- package/dist/node/mdx/remarkPlugins/link.d.ts +2 -1
- package/dist/node/mdx/remarkPlugins/link.js +8 -7
- package/dist/node/mdx/remarkPlugins/toc.js +1 -1
- package/dist/node/medium-zoom/index.js +1 -1
- package/dist/node/route/RoutePage.d.ts +0 -1
- package/dist/node/route/RoutePage.js +4 -6
- package/dist/node/route/RouteService.js +1 -1
- package/dist/node/route/extractPageData.js +3 -15
- package/dist/node/route/normalizeRoutePath.js +2 -3
- package/dist/node/runtimeModule/i18n.js +3 -3
- package/dist/node/runtimeModule/pageData/createPageData.js +1 -1
- package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
- package/dist/node/runtimeModule/searchHooks.js +1 -1
- package/dist/node/runtimeModule/siteData/createSiteData.js +1 -1
- package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
- package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +1 -1
- package/dist/node/serve.js +1 -1
- package/dist/node/ssg/alternateLinks.js +1 -1
- package/dist/node/ssg/htmlFile.js +1 -1
- package/dist/node/ssg/renderHtmlTemplate.js +1 -1
- package/dist/node/ssg/renderPage.js +3 -3
- package/dist/node/ssg/renderPageWorker.js +2 -2
- package/dist/node/ssg/renderPages.js +6 -6
- package/dist/node/ssg/rsbuildPluginSSG.js +1 -1
- package/dist/node/ssg/ssgEnv.js +1 -1
- package/dist/node/ssg-md/llms/emitLlmsTxt.js +1 -1
- package/dist/node/ssg-md/llms/llmsTxt.js +1 -1
- package/dist/node/ssg-md/remarkSplitMdx.js +8 -10
- package/dist/node/ssg-md/renderPage.js +3 -3
- package/dist/node/ssg-md/renderPages.js +4 -4
- package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -1
- package/dist/node/utils/checkLanguageParity.js +1 -1
- package/dist/node/utils/createHash.js +1 -1
- package/dist/node/utils/error.js +2 -2
- package/dist/node/utils/flattenMdxContent.js +2 -2
- package/dist/node/utils/fs.js +1 -1
- package/dist/node/utils/getPageKey.js +1 -1
- package/dist/node/utils/normalizePath.js +1 -1
- package/dist/node/utils/reactAlias.js +3 -3
- package/dist/runtime/App.js +7 -4
- package/dist/runtime/csrClientEntry.js +7 -2
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/reactDom.d.ts +19 -0
- package/dist/runtime/reactDom.js +5 -0
- package/dist/runtime/route.d.ts +10 -0
- package/dist/runtime/route.js +13 -2
- package/dist/runtime/ssrClientEntry.js +2 -0
- package/dist/theme/components/HoverGroup/index.css +15 -0
- package/dist/theme/components/HoverGroup/index.js +17 -1
- package/dist/theme/components/Llms/LlmsCopyButton.js +3 -4
- package/dist/theme/components/Llms/LlmsCopyRow.js +2 -3
- package/dist/theme/components/Llms/LlmsHint.d.ts +2 -0
- package/dist/theme/components/Llms/LlmsHint.js +44 -0
- package/dist/theme/components/Llms/getLlmsCopyContent.d.ts +1 -0
- package/dist/theme/components/Llms/getLlmsCopyContent.js +14 -0
- package/dist/theme/components/Llms/index.d.ts +1 -1
- package/dist/theme/components/Llms/index.js +1 -1
- package/dist/theme/components/Nav/NavMenu.css +15 -0
- package/dist/theme/components/Nav/NavMenu.js +8 -0
- package/dist/theme/components/Nav/hooks.js +1 -2
- package/dist/theme/components/NavScreen/NavScreenMenuItem.css +17 -2
- package/dist/theme/components/NavScreen/NavScreenMenuItem.js +21 -22
- package/dist/theme/components/NavScreen/index.css +4 -0
- package/dist/theme/components/Outline/index.css +4 -0
- package/dist/theme/components/Search/logic/providers/LocalProvider.js +1 -1
- package/dist/theme/components/Sidebar/SidebarGroup.js +4 -1
- package/dist/theme/components/Sidebar/SidebarItem.css +15 -0
- package/dist/theme/components/Sidebar/SidebarItem.d.ts +2 -1
- package/dist/theme/components/Sidebar/SidebarItem.js +7 -2
- package/dist/theme/components/Sidebar/SidebarSectionHeader.css +14 -0
- package/dist/theme/components/Sidebar/SidebarSectionHeader.d.ts +2 -1
- package/dist/theme/components/Sidebar/SidebarSectionHeader.js +12 -6
- package/dist/theme/components/Sidebar/index.js +1 -0
- package/dist/theme/components/SwitchAppearance/global.css +3 -16
- package/dist/theme/index.d.ts +1 -2
- package/dist/theme/index.js +1 -2
- package/dist/theme/layout/Layout/index.js +1 -2
- package/dist/theme/logic/utils.d.ts +4 -0
- package/dist/theme/logic/utils.js +23 -2
- package/dist/theme/styles/preflight.css +0 -2
- package/meta-json-schema.json +33 -3
- package/nav-json-schema.json +9 -0
- package/package.json +18 -23
- package/dist/5871.js +0 -7275
- package/dist/5871.js.LICENSE.txt +0 -41
- package/dist/eject-theme/components/Llms/LlmsHiddenHint.test.tsx +0 -23
- package/dist/eject-theme/components/Llms/LlmsHiddenHint.tsx +0 -15
- package/dist/theme/components/Llms/LlmsHiddenHint.d.ts +0 -1
- package/dist/theme/components/Llms/LlmsHiddenHint.js +0 -18
- package/dist/theme/logic/useRedirect4FirstVisit.d.ts +0 -5
- package/dist/theme/logic/useRedirect4FirstVisit.js +0 -31
- /package/dist/{102.js → 102~0.js} +0 -0
- /package/dist/{7748.js → 7748~0.js} +0 -0
- /package/dist/{0~8016.js → 8016~0.js} +0 -0
- /package/dist/{9857.js → 9857~0.js} +0 -0
- /package/dist/{9940.js → 9940~0.js} +0 -0
- /package/dist/{0~rslib-runtime.js → rslib-runtime~0.js} +0 -0
- /package/dist/{0~tinypool.js → tinypool~0.js} +0 -0
|
@@ -5,13 +5,13 @@ import { IconCopy, IconSuccess, SvgWrapper, copyToClipboard } from "@rspress/cor
|
|
|
5
5
|
import { useCallback, useRef, useState } from "react";
|
|
6
6
|
import "./index.css";
|
|
7
7
|
import "./LlmsCopyButton.css";
|
|
8
|
+
import { getLlmsCopyContent } from "./getLlmsCopyContent.js";
|
|
8
9
|
import { useMdUrl } from "./useMdUrl.js";
|
|
9
10
|
/**
|
|
10
11
|
* Inspired from fumadocs docsite
|
|
11
12
|
* @from https://github.com/fuma-nama/fumadocs/blob/5723bbe58ef805a5421a780abf235a10b251be2f/apps/docs/app/docs/%5B...slug%5D/page.client.tsx#L11
|
|
12
13
|
* @license MIT
|
|
13
|
-
*/
|
|
14
|
-
function LlmsCopyButton(props) {
|
|
14
|
+
*/ function LlmsCopyButton(props) {
|
|
15
15
|
const { onClick, ...otherProps } = props;
|
|
16
16
|
const t = useI18n();
|
|
17
17
|
const { pathname } = useMdUrl();
|
|
@@ -22,8 +22,7 @@ function LlmsCopyButton(props) {
|
|
|
22
22
|
setLoading(true);
|
|
23
23
|
const url = pathname;
|
|
24
24
|
try {
|
|
25
|
-
const content =
|
|
26
|
-
cache.set(url, content);
|
|
25
|
+
const content = await getLlmsCopyContent(url);
|
|
27
26
|
const isCopied = await copyToClipboard(content);
|
|
28
27
|
if (!isCopied) return;
|
|
29
28
|
setFinished(true);
|
|
@@ -2,8 +2,8 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useI18n } from "@rspress/core/runtime";
|
|
3
3
|
import { IconCopy, IconSuccess, SvgWrapper, copyToClipboard } from "@rspress/core/theme";
|
|
4
4
|
import { useCallback, useRef, useState } from "react";
|
|
5
|
+
import { getLlmsCopyContent } from "./getLlmsCopyContent.js";
|
|
5
6
|
import { useMdUrl } from "./useMdUrl.js";
|
|
6
|
-
const cache = new Map();
|
|
7
7
|
function LlmsCopyRow() {
|
|
8
8
|
const t = useI18n();
|
|
9
9
|
const { pathname } = useMdUrl();
|
|
@@ -14,8 +14,7 @@ function LlmsCopyRow() {
|
|
|
14
14
|
if (!pathname) return;
|
|
15
15
|
setLoading(true);
|
|
16
16
|
try {
|
|
17
|
-
const content =
|
|
18
|
-
cache.set(pathname, content);
|
|
17
|
+
const content = await getLlmsCopyContent(pathname);
|
|
19
18
|
const isCopied = await copyToClipboard(content);
|
|
20
19
|
if (!isCopied) return;
|
|
21
20
|
setFinished(true);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { routePathToMdPath, usePage, useSite, withBase, withSiteOrigin } from "@rspress/core/runtime";
|
|
3
|
+
const visuallyHiddenStyle = {
|
|
4
|
+
position: 'absolute',
|
|
5
|
+
width: 1,
|
|
6
|
+
height: 1,
|
|
7
|
+
padding: 0,
|
|
8
|
+
margin: -1,
|
|
9
|
+
overflow: 'hidden',
|
|
10
|
+
clip: 'rect(0, 0, 0, 0)',
|
|
11
|
+
clipPath: 'inset(50%)',
|
|
12
|
+
whiteSpace: 'nowrap',
|
|
13
|
+
border: 0
|
|
14
|
+
};
|
|
15
|
+
function createLlmsHintText({ llmsTxtUrl, llmsFullTxtUrl, pageMdUrl }) {
|
|
16
|
+
const text = `For AI agents: the complete documentation index is available at ${llmsTxtUrl}, the full documentation bundle is available at ${llmsFullTxtUrl}`;
|
|
17
|
+
return pageMdUrl ? `${text}, and this page is available as Markdown at ${pageMdUrl}.` : `${text}.`;
|
|
18
|
+
}
|
|
19
|
+
function LlmsHint() {
|
|
20
|
+
const { page } = usePage();
|
|
21
|
+
const { site } = useSite();
|
|
22
|
+
if (!page?.routePath) return null;
|
|
23
|
+
const isMultiVersion = site.multiVersion.versions.length > 0;
|
|
24
|
+
const versionPrefix = isMultiVersion && page.version !== site.multiVersion.default ? `${page.version}/` : '';
|
|
25
|
+
const langPrefix = page.lang === site.lang ? '' : `${page.lang}/`;
|
|
26
|
+
const llmsTxtUrl = withSiteOrigin(withBase(`/${versionPrefix}${langPrefix}llms.txt`));
|
|
27
|
+
const llmsFullTxtUrl = withSiteOrigin(withBase(`/${versionPrefix}${langPrefix}llms-full.txt`));
|
|
28
|
+
if (import.meta.env.SSG_MD) return `> ${createLlmsHintText({
|
|
29
|
+
llmsTxtUrl,
|
|
30
|
+
llmsFullTxtUrl
|
|
31
|
+
})}\n\n`;
|
|
32
|
+
const pageMdUrl = withSiteOrigin(routePathToMdPath(page.routePath));
|
|
33
|
+
const hintText = createLlmsHintText({
|
|
34
|
+
llmsTxtUrl,
|
|
35
|
+
llmsFullTxtUrl,
|
|
36
|
+
pageMdUrl
|
|
37
|
+
});
|
|
38
|
+
return /*#__PURE__*/ jsx("div", {
|
|
39
|
+
className: "rp-llms-hint",
|
|
40
|
+
style: visuallyHiddenStyle,
|
|
41
|
+
children: hintText
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
export { LlmsHint };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getLlmsCopyContent(url: string): Promise<string>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const cache = new Map();
|
|
2
|
+
const DEV_COPY_WARNING = 'Warning: Markdown content is unavailable in development mode; run `rspress build` to use this feature.';
|
|
3
|
+
async function getLlmsCopyContent(url) {
|
|
4
|
+
if (import.meta.env.DEV) {
|
|
5
|
+
console.warn(DEV_COPY_WARNING);
|
|
6
|
+
return DEV_COPY_WARNING;
|
|
7
|
+
}
|
|
8
|
+
const cachedContent = cache.get(url);
|
|
9
|
+
if (void 0 !== cachedContent) return cachedContent;
|
|
10
|
+
const content = await fetch(url).then((response)=>response.text());
|
|
11
|
+
cache.set(url, content);
|
|
12
|
+
return content;
|
|
13
|
+
}
|
|
14
|
+
export { getLlmsCopyContent };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { LlmsContainer, type LlmsContainerProps } from './LlmsContainer.js';
|
|
2
2
|
export { LlmsCopyButton, type LlmsCopyButtonProps } from './LlmsCopyButton.js';
|
|
3
|
-
export {
|
|
3
|
+
export { LlmsHint } from './LlmsHint.js';
|
|
4
4
|
export { LlmsViewOptions, type LlmsViewOptionsItem, type LlmsViewOptionsProps, } from './LlmsViewOptions.js';
|
|
5
5
|
export { useMdUrl } from './useMdUrl.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { LlmsContainer } from "./LlmsContainer.js";
|
|
2
2
|
export { LlmsCopyButton } from "./LlmsCopyButton.js";
|
|
3
|
-
export {
|
|
3
|
+
export { LlmsHint } from "./LlmsHint.js";
|
|
4
4
|
export { LlmsViewOptions } from "./LlmsViewOptions.js";
|
|
5
5
|
export { useMdUrl } from "./useMdUrl.js";
|
|
@@ -48,6 +48,21 @@
|
|
|
48
48
|
display: flex;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
.rp-nav-menu__item__leading-icon {
|
|
52
|
+
object-fit: contain;
|
|
53
|
+
flex: 0 0 16px;
|
|
54
|
+
width: 16px;
|
|
55
|
+
height: 16px;
|
|
56
|
+
font-size: 16px;
|
|
57
|
+
line-height: 16px;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.rp-nav-menu__item__leading-icon > svg, .rp-nav-menu__item__leading-icon > img {
|
|
61
|
+
object-fit: contain;
|
|
62
|
+
width: 100%;
|
|
63
|
+
height: 100%;
|
|
64
|
+
}
|
|
65
|
+
|
|
51
66
|
.rp-nav-menu__item:hover .rp-nav-menu__item__container {
|
|
52
67
|
color: var(--rp-c-brand);
|
|
53
68
|
text-align: center;
|
|
@@ -19,6 +19,10 @@ function NavMenuItemInner({ menuItem, children }) {
|
|
|
19
19
|
lang: menuItem.lang,
|
|
20
20
|
rel: menuItem.rel,
|
|
21
21
|
children: [
|
|
22
|
+
menuItem.icon && /*#__PURE__*/ jsx(SvgWrapper, {
|
|
23
|
+
icon: menuItem.icon,
|
|
24
|
+
className: "rp-nav-menu__item__leading-icon"
|
|
25
|
+
}),
|
|
22
26
|
menuItem.text,
|
|
23
27
|
menuItem.tag && /*#__PURE__*/ jsx(Tag, {
|
|
24
28
|
tag: menuItem.tag
|
|
@@ -28,6 +32,10 @@ function NavMenuItemInner({ menuItem, children }) {
|
|
|
28
32
|
}) : /*#__PURE__*/ jsxs("div", {
|
|
29
33
|
className: "rp-nav-menu__item__container",
|
|
30
34
|
children: [
|
|
35
|
+
menuItem.icon && /*#__PURE__*/ jsx(SvgWrapper, {
|
|
36
|
+
icon: menuItem.icon,
|
|
37
|
+
className: "rp-nav-menu__item__leading-icon"
|
|
38
|
+
}),
|
|
31
39
|
menuItem.text,
|
|
32
40
|
menuItem.tag && /*#__PURE__*/ jsx(Tag, {
|
|
33
41
|
tag: menuItem.tag
|
|
@@ -5,14 +5,13 @@ function replaceLang(rawUrl, lang, version, cleanUrls, isPageNotFound) {
|
|
|
5
5
|
url = normalizeHrefInRuntime(url);
|
|
6
6
|
let versionPart = '';
|
|
7
7
|
let langPart = '';
|
|
8
|
-
let purePathPart = '';
|
|
9
8
|
const parts = url.split('/').filter(Boolean);
|
|
10
9
|
if (version.current && version.current !== version.default) versionPart = parts.shift() || '';
|
|
11
10
|
if (lang.target !== lang.default) {
|
|
12
11
|
langPart = lang.target;
|
|
13
12
|
if (lang.current !== lang.default) parts.shift();
|
|
14
13
|
} else parts.shift();
|
|
15
|
-
purePathPart = parts.join('/') || '';
|
|
14
|
+
let purePathPart = parts.join('/') || '';
|
|
16
15
|
if ((versionPart || langPart) && !purePathPart) purePathPart = cleanUrls ? 'index' : 'index.html';
|
|
17
16
|
return addLeadingSlash([
|
|
18
17
|
versionPart,
|
|
@@ -35,12 +35,27 @@
|
|
|
35
35
|
line-height: 22px;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
.rp-nav-screen-menu-
|
|
38
|
+
.rp-nav-screen-menu-item__arrow {
|
|
39
39
|
transition: transform .25s ease-in;
|
|
40
40
|
transform: rotate(-90deg);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
.rp-nav-screen-menu-
|
|
43
|
+
.rp-nav-screen-menu-item__icon {
|
|
44
|
+
object-fit: contain;
|
|
45
|
+
flex: 0 0 16px;
|
|
46
|
+
width: 16px;
|
|
47
|
+
height: 16px;
|
|
48
|
+
font-size: 16px;
|
|
49
|
+
line-height: 16px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.rp-nav-screen-menu-item__icon > svg, .rp-nav-screen-menu-item__icon > img {
|
|
53
|
+
object-fit: contain;
|
|
54
|
+
width: 100%;
|
|
55
|
+
height: 100%;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.rp-nav-screen-menu-item--open .rp-nav-screen-menu-item__arrow {
|
|
44
59
|
transform: rotate(0);
|
|
45
60
|
}
|
|
46
61
|
|
|
@@ -8,6 +8,20 @@ const SvgDown = (props)=>/*#__PURE__*/ jsx(SvgWrapper, {
|
|
|
8
8
|
icon: IconArrowDown,
|
|
9
9
|
...props
|
|
10
10
|
});
|
|
11
|
+
function NavScreenMenuItemContent({ menuItem }) {
|
|
12
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
13
|
+
children: [
|
|
14
|
+
menuItem.icon && /*#__PURE__*/ jsx(SvgWrapper, {
|
|
15
|
+
icon: menuItem.icon,
|
|
16
|
+
className: "rp-nav-screen-menu-item__icon"
|
|
17
|
+
}),
|
|
18
|
+
menuItem.text,
|
|
19
|
+
menuItem.tag && /*#__PURE__*/ jsx(Tag, {
|
|
20
|
+
tag: menuItem.tag
|
|
21
|
+
})
|
|
22
|
+
]
|
|
23
|
+
});
|
|
24
|
+
}
|
|
11
25
|
function NavScreenMenuItemRaw({ left, right, isOpen, isActive, onClick, href, download }) {
|
|
12
26
|
if (href) return /*#__PURE__*/ jsxs(Link, {
|
|
13
27
|
href: href,
|
|
@@ -47,13 +61,8 @@ function NavScreenMenuItemWithLink({ menuItem }) {
|
|
|
47
61
|
pathname
|
|
48
62
|
]);
|
|
49
63
|
return /*#__PURE__*/ jsx(NavScreenMenuItemRaw, {
|
|
50
|
-
left: /*#__PURE__*/
|
|
51
|
-
|
|
52
|
-
menuItem.text,
|
|
53
|
-
menuItem.tag && /*#__PURE__*/ jsx(Tag, {
|
|
54
|
-
tag: menuItem.tag
|
|
55
|
-
})
|
|
56
|
-
]
|
|
64
|
+
left: /*#__PURE__*/ jsx(NavScreenMenuItemContent, {
|
|
65
|
+
menuItem: menuItem
|
|
57
66
|
}),
|
|
58
67
|
right: null,
|
|
59
68
|
href: menuItem.link,
|
|
@@ -66,16 +75,11 @@ function NavScreenMenuItemWithChildren({ menuItem }) {
|
|
|
66
75
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
67
76
|
children: [
|
|
68
77
|
/*#__PURE__*/ jsx(NavScreenMenuItemRaw, {
|
|
69
|
-
left: /*#__PURE__*/
|
|
70
|
-
|
|
71
|
-
menuItem.text,
|
|
72
|
-
menuItem.tag && /*#__PURE__*/ jsx(Tag, {
|
|
73
|
-
tag: menuItem.tag
|
|
74
|
-
})
|
|
75
|
-
]
|
|
78
|
+
left: /*#__PURE__*/ jsx(NavScreenMenuItemContent, {
|
|
79
|
+
menuItem: menuItem
|
|
76
80
|
}),
|
|
77
81
|
right: /*#__PURE__*/ jsx(SvgDown, {
|
|
78
|
-
className: "rp-nav-screen-menu-
|
|
82
|
+
className: "rp-nav-screen-menu-item__arrow"
|
|
79
83
|
}),
|
|
80
84
|
isOpen: isOpen,
|
|
81
85
|
onClick: ()=>setIsOpen(!isOpen),
|
|
@@ -107,13 +111,8 @@ function NavScreenMenuItem({ menuItem }) {
|
|
|
107
111
|
menuItem: menuItem
|
|
108
112
|
});
|
|
109
113
|
return /*#__PURE__*/ jsx(NavScreenMenuItemRaw, {
|
|
110
|
-
left: /*#__PURE__*/
|
|
111
|
-
|
|
112
|
-
menuItem.text,
|
|
113
|
-
menuItem.tag && /*#__PURE__*/ jsx(Tag, {
|
|
114
|
-
tag: menuItem.tag
|
|
115
|
-
})
|
|
116
|
-
]
|
|
114
|
+
left: /*#__PURE__*/ jsx(NavScreenMenuItemContent, {
|
|
115
|
+
menuItem: menuItem
|
|
117
116
|
}),
|
|
118
117
|
right: null
|
|
119
118
|
});
|
|
@@ -7,7 +7,7 @@ const cjkRegex = /[\u3131-\u314e|\u314f-\u3163|\uac00-\ud7a3]|[\u4E00-\u9FCC\u34
|
|
|
7
7
|
const cyrillicRegex = /[\u0400-\u04FF]/g;
|
|
8
8
|
function tokenize(str, regex) {
|
|
9
9
|
const words = [];
|
|
10
|
-
let m
|
|
10
|
+
let m;
|
|
11
11
|
do {
|
|
12
12
|
m = regex.exec(str);
|
|
13
13
|
if (m) words.push(m[0]);
|
|
@@ -42,6 +42,7 @@ function SidebarGroup(props) {
|
|
|
42
42
|
/*#__PURE__*/ jsx(SidebarItemRaw, {
|
|
43
43
|
active: Boolean(active),
|
|
44
44
|
link: item.link,
|
|
45
|
+
icon: item.icon,
|
|
45
46
|
tag: item.tag,
|
|
46
47
|
text: item.text,
|
|
47
48
|
context: item.context,
|
|
@@ -83,7 +84,9 @@ function SidebarGroup(props) {
|
|
|
83
84
|
depth: depth + 1,
|
|
84
85
|
dividerType: item.dividerType
|
|
85
86
|
}, index) : isSidebarSectionHeader(item) ? /*#__PURE__*/ jsx(SidebarSectionHeader, {
|
|
86
|
-
|
|
87
|
+
icon: item.icon,
|
|
88
|
+
sectionHeaderText: item.sectionHeaderText,
|
|
89
|
+
tag: item.tag
|
|
87
90
|
}, index) : /*#__PURE__*/ jsx(SidebarItem, {
|
|
88
91
|
item: item,
|
|
89
92
|
depth: depth + 1,
|
|
@@ -70,6 +70,21 @@
|
|
|
70
70
|
display: flex;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
.rp-sidebar-item__icon {
|
|
74
|
+
object-fit: contain;
|
|
75
|
+
flex: 0 0 16px;
|
|
76
|
+
width: 16px;
|
|
77
|
+
height: 16px;
|
|
78
|
+
font-size: 16px;
|
|
79
|
+
line-height: 16px;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.rp-sidebar-item__icon > svg, .rp-sidebar-item__icon > img {
|
|
83
|
+
object-fit: contain;
|
|
84
|
+
width: 100%;
|
|
85
|
+
height: 100%;
|
|
86
|
+
}
|
|
87
|
+
|
|
73
88
|
.rp-sidebar-item__right {
|
|
74
89
|
align-items: center;
|
|
75
90
|
display: flex;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { NormalizedSidebarGroup, SidebarItem as SidebarItemType } from '@rspress/core';
|
|
2
2
|
import type React from 'react';
|
|
3
3
|
import './SidebarItem.scss';
|
|
4
|
-
export declare function SidebarItemRaw({ active, text, tag, link, context, className, left, right, onClick, depth, }: {
|
|
4
|
+
export declare function SidebarItemRaw({ active, text, icon, tag, link, context, className, left, right, onClick, depth, }: {
|
|
5
5
|
className?: string;
|
|
6
6
|
active: boolean;
|
|
7
7
|
text: string;
|
|
8
|
+
icon: SidebarItemType['icon'];
|
|
8
9
|
tag: SidebarItemType['tag'];
|
|
9
10
|
link: string | undefined;
|
|
10
11
|
depth: number;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useActiveMatcher } from "@rspress/core/runtime";
|
|
3
|
-
import { Link, Tag, renderInlineMarkdown } from "@rspress/core/theme";
|
|
3
|
+
import { Link, SvgWrapper, Tag, renderInlineMarkdown } from "@rspress/core/theme";
|
|
4
4
|
import clsx from "clsx";
|
|
5
5
|
import { useEffect, useRef, useTransition } from "react";
|
|
6
6
|
import "./SidebarItem.css";
|
|
7
7
|
import scroll_into_view_if_needed from "scroll-into-view-if-needed";
|
|
8
|
-
function SidebarItemRaw({ active, text, tag, link, context, className, left, right, onClick, depth }) {
|
|
8
|
+
function SidebarItemRaw({ active, text, icon, tag, link, context, className, left, right, onClick, depth }) {
|
|
9
9
|
const ref = useRef(null);
|
|
10
10
|
const [isPending, startTransition] = useTransition();
|
|
11
11
|
useEffect(()=>{
|
|
@@ -27,6 +27,10 @@ function SidebarItemRaw({ active, text, tag, link, context, className, left, rig
|
|
|
27
27
|
className: "rp-sidebar-item__left",
|
|
28
28
|
ref: ref,
|
|
29
29
|
children: [
|
|
30
|
+
icon && /*#__PURE__*/ jsx(SvgWrapper, {
|
|
31
|
+
icon: icon,
|
|
32
|
+
className: "rp-sidebar-item__icon"
|
|
33
|
+
}),
|
|
30
34
|
/*#__PURE__*/ jsx("span", {
|
|
31
35
|
className: "rp-doc",
|
|
32
36
|
...renderInlineMarkdown(text)
|
|
@@ -86,6 +90,7 @@ function SidebarItem(props) {
|
|
|
86
90
|
className: className,
|
|
87
91
|
active: active,
|
|
88
92
|
link: item.link,
|
|
93
|
+
icon: item.icon,
|
|
89
94
|
tag: item.tag,
|
|
90
95
|
text: item.text,
|
|
91
96
|
context: item.context,
|
|
@@ -13,11 +13,25 @@
|
|
|
13
13
|
.rp-sidebar-section-header__left {
|
|
14
14
|
color: var(--rp-c-text-1);
|
|
15
15
|
align-items: center;
|
|
16
|
+
gap: 4px;
|
|
16
17
|
font-size: 14px;
|
|
17
18
|
font-weight: 600;
|
|
18
19
|
display: flex;
|
|
19
20
|
}
|
|
20
21
|
|
|
22
|
+
.rp-sidebar-section-header__icon {
|
|
23
|
+
object-fit: contain;
|
|
24
|
+
flex: 0 0 16px;
|
|
25
|
+
width: 16px;
|
|
26
|
+
height: 16px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.rp-sidebar-section-header__icon > svg, .rp-sidebar-section-header__icon > img {
|
|
30
|
+
object-fit: contain;
|
|
31
|
+
width: 100%;
|
|
32
|
+
height: 100%;
|
|
33
|
+
}
|
|
34
|
+
|
|
21
35
|
.rp-sidebar-section-header__right {
|
|
22
36
|
align-items: center;
|
|
23
37
|
display: flex;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import './SidebarSectionHeader.scss';
|
|
2
|
-
export declare function SidebarSectionHeader({ sectionHeaderText, tag, }: {
|
|
2
|
+
export declare function SidebarSectionHeader({ icon, sectionHeaderText, tag, }: {
|
|
3
|
+
icon?: string;
|
|
3
4
|
sectionHeaderText: string;
|
|
4
5
|
tag?: string;
|
|
5
6
|
}): import("react").JSX.Element;
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Tag, renderInlineMarkdown } from "@rspress/core/theme";
|
|
2
|
+
import { SvgWrapper, Tag, renderInlineMarkdown } from "@rspress/core/theme";
|
|
3
3
|
import "./SidebarSectionHeader.css";
|
|
4
|
-
function SidebarSectionHeader({ sectionHeaderText, tag }) {
|
|
4
|
+
function SidebarSectionHeader({ icon, sectionHeaderText, tag }) {
|
|
5
5
|
return /*#__PURE__*/ jsxs("div", {
|
|
6
6
|
className: "rp-sidebar-section-header",
|
|
7
7
|
children: [
|
|
8
|
-
/*#__PURE__*/
|
|
8
|
+
/*#__PURE__*/ jsxs("div", {
|
|
9
9
|
className: "rp-sidebar-section-header__left",
|
|
10
|
-
children:
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
children: [
|
|
11
|
+
icon && /*#__PURE__*/ jsx(SvgWrapper, {
|
|
12
|
+
icon: icon,
|
|
13
|
+
className: "rp-sidebar-section-header__icon"
|
|
14
|
+
}),
|
|
15
|
+
/*#__PURE__*/ jsx("span", {
|
|
16
|
+
...renderInlineMarkdown(sectionHeaderText)
|
|
17
|
+
})
|
|
18
|
+
]
|
|
13
19
|
}),
|
|
14
20
|
/*#__PURE__*/ jsx("div", {
|
|
15
21
|
className: "rp-sidebar-section-header__right",
|
|
@@ -28,6 +28,7 @@ function SidebarListItem(props) {
|
|
|
28
28
|
dividerType: item.dividerType
|
|
29
29
|
}, index);
|
|
30
30
|
if (isSidebarSectionHeader(item)) return /*#__PURE__*/ jsx(SidebarSectionHeader, {
|
|
31
|
+
icon: item.icon,
|
|
31
32
|
sectionHeaderText: item.sectionHeaderText,
|
|
32
33
|
tag: item.tag
|
|
33
34
|
}, index);
|
|
@@ -1,26 +1,13 @@
|
|
|
1
|
-
::view-transition-old(root) {
|
|
1
|
+
::view-transition-old(root), ::view-transition-new(root) {
|
|
2
2
|
mix-blend-mode: normal;
|
|
3
3
|
animation: none;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
::view-transition-new(root) {
|
|
7
|
-
mix-blend-mode: normal;
|
|
8
|
-
animation: none;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
::view-transition-old(root) {
|
|
12
|
-
z-index: 1;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.dark::view-transition-new(root) {
|
|
6
|
+
::view-transition-old(root), .dark::view-transition-new(root) {
|
|
16
7
|
z-index: 1;
|
|
17
8
|
}
|
|
18
9
|
|
|
19
|
-
::view-transition-new(root) {
|
|
20
|
-
z-index: 9999;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.dark::view-transition-old(root) {
|
|
10
|
+
::view-transition-new(root), .dark::view-transition-old(root) {
|
|
24
11
|
z-index: 9999;
|
|
25
12
|
}
|
|
26
13
|
|
package/dist/theme/index.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export { useHoverGroup } from './components/HoverGroup/useHoverGroup.js';
|
|
|
21
21
|
export { LastUpdated } from './components/LastUpdated/index.js';
|
|
22
22
|
export { Link, type LinkProps } from './components/Link/index.js';
|
|
23
23
|
export { useLinkNavigate } from './components/Link/useLinkNavigate.js';
|
|
24
|
-
export { LlmsContainer, type LlmsContainerProps, LlmsCopyButton, type LlmsCopyButtonProps,
|
|
24
|
+
export { LlmsContainer, type LlmsContainerProps, LlmsCopyButton, type LlmsCopyButtonProps, LlmsHint, LlmsViewOptions, type LlmsViewOptionsItem, type LlmsViewOptionsProps, useMdUrl, } from './components/Llms/index.js';
|
|
25
25
|
export { LlmsCopyRow } from './components/Llms/LlmsCopyRow.js';
|
|
26
26
|
export { LlmsOpenRow } from './components/Llms/LlmsOpenRow.js';
|
|
27
27
|
export { Nav, type NavProps } from './components/Nav/index.js';
|
|
@@ -63,7 +63,6 @@ export { getCopyableText } from './logic/getCopyableText.js';
|
|
|
63
63
|
export { mergeRefs } from './logic/mergeRefs.js';
|
|
64
64
|
export { useFullTextSearch } from './logic/useFullTextSearch.js';
|
|
65
65
|
export { usePrevNextPage } from './logic/usePrevNextPage.js';
|
|
66
|
-
export { useRedirect4FirstVisit } from './logic/useRedirect4FirstVisit.js';
|
|
67
66
|
export { useScrollAfterNav } from './logic/useScrollAfterNav.js';
|
|
68
67
|
export { useScrollReset } from './logic/useScrollReset.js';
|
|
69
68
|
export { useSetup } from './logic/useSetup.js';
|
package/dist/theme/index.js
CHANGED
|
@@ -21,7 +21,7 @@ export { useHoverGroup } from "./components/HoverGroup/useHoverGroup.js";
|
|
|
21
21
|
export { LastUpdated } from "./components/LastUpdated/index.js";
|
|
22
22
|
export { Link } from "./components/Link/index.js";
|
|
23
23
|
export { useLinkNavigate } from "./components/Link/useLinkNavigate.js";
|
|
24
|
-
export { LlmsContainer, LlmsCopyButton,
|
|
24
|
+
export { LlmsContainer, LlmsCopyButton, LlmsHint, LlmsViewOptions, useMdUrl } from "./components/Llms/index.js";
|
|
25
25
|
export { LlmsCopyRow } from "./components/Llms/LlmsCopyRow.js";
|
|
26
26
|
export { LlmsOpenRow } from "./components/Llms/LlmsOpenRow.js";
|
|
27
27
|
export { Nav } from "./components/Nav/index.js";
|
|
@@ -61,7 +61,6 @@ export { getCopyableText } from "./logic/getCopyableText.js";
|
|
|
61
61
|
export { mergeRefs } from "./logic/mergeRefs.js";
|
|
62
62
|
export { useFullTextSearch } from "./logic/useFullTextSearch.js";
|
|
63
63
|
export { usePrevNextPage } from "./logic/usePrevNextPage.js";
|
|
64
|
-
export { useRedirect4FirstVisit } from "./logic/useRedirect4FirstVisit.js";
|
|
65
64
|
export { useScrollAfterNav } from "./logic/useScrollAfterNav.js";
|
|
66
65
|
export { useScrollReset } from "./logic/useScrollReset.js";
|
|
67
66
|
export { useSetup } from "./logic/useSetup.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Content, useFrontmatter, useLocaleSiteData, usePage, useSite } from "@rspress/core/runtime";
|
|
3
|
-
import { DocLayout, HomeLayout as theme_HomeLayout, Nav, NotFoundLayout as theme_NotFoundLayout,
|
|
3
|
+
import { DocLayout, HomeLayout as theme_HomeLayout, Nav, NotFoundLayout as theme_NotFoundLayout, useScrollReset, useSetup } from "@rspress/core/theme";
|
|
4
4
|
import { Head, useHead } from "@unhead/react";
|
|
5
5
|
import react, { memo, useMemo } from "react";
|
|
6
6
|
const concatTitle = (title, suffix)=>{
|
|
@@ -116,7 +116,6 @@ function Layout(props) {
|
|
|
116
116
|
});
|
|
117
117
|
useSetup();
|
|
118
118
|
useScrollReset();
|
|
119
|
-
useRedirect4FirstVisit();
|
|
120
119
|
const { frontmatter: { navbar: showNavbar = true } } = useFrontmatter();
|
|
121
120
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
122
121
|
children: [
|
|
@@ -23,6 +23,10 @@ export declare function renderInlineMarkdown(text: string): {
|
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
25
|
/**
|
|
26
|
+
* Parse a header text to plain text, which can be used in attributes like `title`. Both the inline markdown syntax and
|
|
27
|
+
* the HTML are stripped, because a header is markdown when it comes from the remark toc plugin, and HTML when it is
|
|
28
|
+
* collected from the DOM by `useDynamicToc`, carrying the markup of the components rendered in the heading.
|
|
29
|
+
* @param mdx The header text to parse, either markdown or HTML.
|
|
26
30
|
* @internal
|
|
27
31
|
* @private
|
|
28
32
|
*/
|
|
@@ -20,11 +20,32 @@ const CODE_TEXT_PATTERN = /`(.*?)`/g;
|
|
|
20
20
|
const STRONG_TEXT_PATTERN = /\*{2}(?!\*)(.*?)\*{2}(?!\*)/g;
|
|
21
21
|
const EMPHASIS_TEXT_PATTERN = /\*(?!\*)(.*?)\*(?!\*)/g;
|
|
22
22
|
const DELETE_TEXT_PATTERN = /~{2}(.*?)~{2}/g;
|
|
23
|
+
const INLINE_CODE_PATTERN = /`[^`]+`/g;
|
|
24
|
+
const HTML_TAG_PATTERN = /<\/?[a-z][^>]*>/gi;
|
|
25
|
+
const HTML_ENTITY_PATTERN = /&(#\d+|#x[0-9a-f]+|[a-z][0-9a-z]*);/gi;
|
|
26
|
+
const NAMED_HTML_ENTITIES = {
|
|
27
|
+
amp: '&',
|
|
28
|
+
apos: "'",
|
|
29
|
+
gt: '>',
|
|
30
|
+
lt: '<',
|
|
31
|
+
nbsp: '\u00A0',
|
|
32
|
+
quot: '"'
|
|
33
|
+
};
|
|
34
|
+
function decodeHtmlEntities(text) {
|
|
35
|
+
return text.replace(HTML_ENTITY_PATTERN, (match, entity)=>{
|
|
36
|
+
if (!entity.startsWith('#')) return NAMED_HTML_ENTITIES[entity.toLowerCase()] ?? match;
|
|
37
|
+
const isHex = 'x' === entity[1] || 'X' === entity[1];
|
|
38
|
+
const codePoint = Number.parseInt(isHex ? entity.slice(2) : entity.slice(1), isHex ? 16 : 10);
|
|
39
|
+
const isScalarValue = codePoint <= 0x10ffff && !(codePoint >= 0xd800 && codePoint <= 0xdfff);
|
|
40
|
+
return isScalarValue ? String.fromCodePoint(codePoint) : match;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
23
43
|
function renderInlineMarkdown(text) {
|
|
24
|
-
const htmlText = text.replace(
|
|
44
|
+
const htmlText = text.replace(INLINE_CODE_PATTERN, (match)=>match.replace(/</g, '<')).replace(STRONG_TEXT_PATTERN, '<strong>$1</strong>').replace(EMPHASIS_TEXT_PATTERN, '<em>$1</em>').replace(DELETE_TEXT_PATTERN, '<del>$1</del>').replace(CODE_TEXT_PATTERN, '<code>$1</code>');
|
|
25
45
|
return renderHtmlOrText(htmlText);
|
|
26
46
|
}
|
|
27
47
|
function parseInlineMarkdownText(mdx) {
|
|
28
|
-
|
|
48
|
+
const plainText = mdx.replace(INLINE_CODE_PATTERN, (match)=>match.replace(/</g, '<')).replace(STRONG_TEXT_PATTERN, '$1').replace(EMPHASIS_TEXT_PATTERN, '$1').replace(DELETE_TEXT_PATTERN, '$1').replace(CODE_TEXT_PATTERN, '$1').replace(HTML_TAG_PATTERN, '');
|
|
49
|
+
return decodeHtmlEntities(plainText).trim();
|
|
29
50
|
}
|
|
30
51
|
export { parseInlineMarkdownText, renderHtmlOrText, renderInlineMarkdown };
|
|
@@ -27,7 +27,6 @@ hr {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
abbr:where([title]) {
|
|
30
|
-
-webkit-text-decoration: underline dotted;
|
|
31
30
|
text-decoration: underline dotted;
|
|
32
31
|
}
|
|
33
32
|
|
|
@@ -38,7 +37,6 @@ h1, h2, h3, h4, h5, h6 {
|
|
|
38
37
|
|
|
39
38
|
a {
|
|
40
39
|
color: inherit;
|
|
41
|
-
-webkit-text-decoration: inherit;
|
|
42
40
|
text-decoration: inherit;
|
|
43
41
|
}
|
|
44
42
|
|