@rspress/core 2.0.0-rc.5 → 2.0.0-rc.6
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.4468968d.js → 0~7675.d236b058.js} +3 -3
- package/dist/{5485.b9ce9bdf.js → 5485.7586c86a.js} +1 -1
- package/dist/{5341.9eb6b114.js → 7786.421b464f.js} +2 -2
- package/dist/{1820.985588a0.js → 9348.1beb3e25.js} +6 -0
- package/dist/cli/index.js +2 -2
- package/dist/config/defineConfig.d.ts +40 -0
- package/dist/{cli/config → config}/loadConfigFile.js +2 -2
- package/dist/eject-theme/components/Callout/index.scss +6 -6
- package/dist/eject-theme/components/DocContent/docComponents/title.tsx +21 -2
- package/dist/eject-theme/components/Llms/LlmsContainer.scss +6 -0
- package/dist/eject-theme/components/Llms/LlmsContainer.tsx +9 -0
- package/dist/eject-theme/components/Llms/LlmsCopyButton.scss +57 -0
- package/dist/eject-theme/components/Llms/LlmsCopyButton.tsx +94 -0
- package/dist/eject-theme/components/Llms/LlmsViewOptions.scss +98 -0
- package/dist/eject-theme/components/Llms/LlmsViewOptions.tsx +259 -0
- package/dist/eject-theme/components/Llms/index.scss +42 -0
- package/dist/eject-theme/components/Llms/index.tsx +4 -0
- package/dist/eject-theme/components/Llms/useMdUrl.ts +14 -0
- package/dist/eject-theme/components/Nav/index.scss +3 -0
- package/dist/eject-theme/components/Nav/index.tsx +7 -2
- package/dist/eject-theme/components/{Nav/NavTitle.tsx → NavTitle/index.tsx} +15 -6
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -3
- package/dist/node/PluginDriver.js +1 -1
- package/dist/node/auto-nav-sidebar/index.js +1 -1
- package/dist/node/auto-nav-sidebar/normalize.js +1 -1
- package/dist/node/auto-nav-sidebar/utils.js +1 -1
- package/dist/node/auto-nav-sidebar/walk.js +1 -1
- package/dist/node/constants.js +1 -1
- package/dist/node/eject.js +1 -0
- package/dist/node/initRsbuild.js +5 -4
- package/dist/node/last-updated/index.js +1 -1
- package/dist/node/mdx/{loader.7c249a26.js → loader.15e0b2d2.js} +0 -5
- package/dist/node/mdx/options.js +2 -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 +2 -3
- package/dist/node/mdx/rehypePlugins/shiki.js +1 -1
- package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +1 -2
- package/dist/node/mdx/remarkPlugins/image.js +1 -2
- package/dist/node/mdx/remarkPlugins/link.js +1 -2
- package/dist/node/mdx/remarkPlugins/toc.d.ts +4 -3
- package/dist/node/mdx/remarkPlugins/toc.js +14 -11
- package/dist/node/route/RoutePage.d.ts +3 -1
- package/dist/node/route/RoutePage.js +4 -0
- package/dist/node/route/RouteService.js +2 -2
- package/dist/node/route/extractPageData.d.ts +5 -0
- package/dist/node/route/extractPageData.js +88 -57
- package/dist/node/route/normalizeRoutePath.js +2 -2
- package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.d.ts +21 -0
- package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.js +21 -0
- package/dist/node/runtimeModule/i18n.js +4 -3
- package/dist/node/runtimeModule/pageData/createPageData.js +9 -6
- package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +20 -14
- package/dist/node/runtimeModule/siteData/createSiteData.js +2 -1
- package/dist/node/runtimeModule/siteData/normalizeThemeConfig.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 +7 -3
- package/dist/node/ssg/rsbuildPluginSSG.js +1 -1
- package/dist/node/ssg/ssgEnv.js +1 -1
- package/dist/node/ssg-md/llms/emitLlmsTxt.js +2 -2
- package/dist/node/ssg-md/llms/llmsTxt.js +12 -2
- package/dist/node/ssg-md/remarkSplitMdx.js +2 -2
- package/dist/node/ssg-md/renderPage.js +1 -1
- package/dist/node/ssg-md/renderPages.js +1 -1
- package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -1
- package/dist/node/utils/createHash.js +1 -1
- package/dist/node/utils/flattenMdxContent.js +2 -2
- package/dist/node/utils/getPageKey.js +1 -1
- package/dist/node/utils/normalizePath.js +1 -1
- package/dist/node/utils/reactAlias.js +1 -1
- package/dist/runtime/hooks/useI18n.d.ts +1 -1
- package/dist/runtime/hooks/useI18n.js +2 -2
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.js +2 -2
- package/dist/runtime/utils.d.ts +2 -2
- package/dist/runtime/utils.js +2 -2
- package/dist/theme/components/Callout/index.css +6 -6
- package/dist/theme/components/DocContent/docComponents/title.js +25 -5
- package/dist/theme/components/HomeHero/index.css +10 -10
- package/dist/theme/components/Llms/LlmsContainer.css +7 -0
- package/dist/theme/components/Llms/LlmsContainer.d.ts +5 -0
- package/dist/theme/components/Llms/LlmsContainer.js +9 -0
- package/dist/theme/components/Llms/LlmsCopyButton.css +57 -0
- package/dist/theme/components/Llms/LlmsCopyButton.d.ts +20 -0
- package/dist/theme/components/Llms/LlmsCopyButton.js +73 -0
- package/dist/theme/components/Llms/LlmsCopyButton.js.LICENSE.txt +5 -0
- package/dist/theme/components/Llms/LlmsViewOptions.css +93 -0
- package/dist/theme/components/Llms/LlmsViewOptions.d.ts +34 -0
- package/dist/theme/components/Llms/LlmsViewOptions.js +206 -0
- package/dist/theme/components/Llms/LlmsViewOptions.js.LICENSE.txt +5 -0
- package/dist/theme/components/Llms/index.css +32 -0
- package/dist/theme/components/Llms/index.d.ts +4 -0
- package/dist/theme/components/Llms/index.js +5 -0
- package/dist/theme/components/Llms/useMdUrl.d.ts +6 -0
- package/dist/theme/components/Llms/useMdUrl.js +15 -0
- package/dist/theme/components/Nav/index.css +1 -0
- package/dist/theme/components/Nav/index.js +1 -2
- package/dist/theme/components/{Nav/NavTitle.d.ts → NavTitle/index.d.ts} +1 -1
- package/dist/theme/components/{Nav/NavTitle.js → NavTitle/index.js} +11 -6
- package/dist/theme/components/PageTabs/index.css +1 -1
- package/dist/theme/components/Tabs/index.css +4 -4
- package/dist/theme/hooks/useDynamicToc.d.ts +2 -0
- package/dist/theme/hooks/useDynamicToc.js +3 -1
- package/dist/theme/index.d.ts +2 -0
- package/dist/theme/index.js +3 -1
- package/dist/theme/layout/Layout/index.js +1 -1
- package/package.json +15 -16
- package/dist/8813.4b28f4bb.js +0 -1
- package/dist/cli/config/index.d.ts +0 -2
- /package/dist/{cli/config/index.js → config/defineConfig.js} +0 -0
- /package/dist/{cli/config → config}/loadConfigFile.d.ts +0 -0
- /package/dist/eject-theme/components/{Nav/NavTitle.scss → NavTitle/index.scss} +0 -0
- /package/dist/theme/components/{Nav/NavTitle.css → NavTitle/index.css} +0 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/*! For license information please see LlmsViewOptions.js.LICENSE.txt */
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useI18n, useSite } from "@rspress/core/runtime";
|
|
4
|
+
import { IconDown } from "@theme";
|
|
5
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
6
|
+
import "./index.css";
|
|
7
|
+
import "./LlmsViewOptions.css";
|
|
8
|
+
import { useMdUrl } from "./useMdUrl.js";
|
|
9
|
+
/**
|
|
10
|
+
* Inspired from fumadocs docsite
|
|
11
|
+
* @from https://github.com/fuma-nama/fumadocs/blob/5723bbe58ef805a5421a780abf235a10b251be2f/apps/docs/app/docs/%5B...slug%5D/page.client.tsx#L11
|
|
12
|
+
* @license MIT
|
|
13
|
+
*/ const IconExternalLink = ()=>/*#__PURE__*/ jsxs("svg", {
|
|
14
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
15
|
+
width: "16",
|
|
16
|
+
height: "16",
|
|
17
|
+
viewBox: "0 0 16 16",
|
|
18
|
+
fill: "none",
|
|
19
|
+
children: [
|
|
20
|
+
/*#__PURE__*/ jsx("path", {
|
|
21
|
+
d: "M9.33301 2H13.9997V6.66667",
|
|
22
|
+
stroke: "currentColor",
|
|
23
|
+
strokeWidth: "1.33333",
|
|
24
|
+
strokeLinecap: "round",
|
|
25
|
+
strokeLinejoin: "round"
|
|
26
|
+
}),
|
|
27
|
+
/*#__PURE__*/ jsx("path", {
|
|
28
|
+
d: "M14 9.82457V13C14 13.5523 13.5523 14 13 14H3C2.44772 14 2 13.5523 2 13V3C2 2.44772 2.44772 2 3 2H6",
|
|
29
|
+
stroke: "currentColor",
|
|
30
|
+
strokeWidth: "1.33333",
|
|
31
|
+
strokeLinecap: "round",
|
|
32
|
+
strokeLinejoin: "round"
|
|
33
|
+
}),
|
|
34
|
+
/*#__PURE__*/ jsx("path", {
|
|
35
|
+
d: "M8.59961 7.39996L13.6996 2.29996",
|
|
36
|
+
stroke: "currentColor",
|
|
37
|
+
strokeWidth: "1.33333",
|
|
38
|
+
strokeLinecap: "round",
|
|
39
|
+
strokeLinejoin: "round"
|
|
40
|
+
})
|
|
41
|
+
]
|
|
42
|
+
});
|
|
43
|
+
const DEFAULT_OPTIONS = [
|
|
44
|
+
'markdownLink',
|
|
45
|
+
'chatgpt',
|
|
46
|
+
'claude'
|
|
47
|
+
];
|
|
48
|
+
function LlmsViewOptions({ options: propsOptions }) {
|
|
49
|
+
const { site } = useSite();
|
|
50
|
+
const llmsUI = site?.themeConfig?.llmsUI;
|
|
51
|
+
const options = ('object' == typeof llmsUI ? llmsUI?.viewOptions : propsOptions) ?? DEFAULT_OPTIONS;
|
|
52
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
53
|
+
const dropdownRef = useRef(null);
|
|
54
|
+
useEffect(()=>{
|
|
55
|
+
const handleClickOutside = (event)=>{
|
|
56
|
+
if (dropdownRef.current && event.target && !dropdownRef.current.contains(event.target)) setIsOpen(false);
|
|
57
|
+
};
|
|
58
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
59
|
+
return ()=>{
|
|
60
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
61
|
+
};
|
|
62
|
+
}, []);
|
|
63
|
+
const toggleDropdown = ()=>{
|
|
64
|
+
setIsOpen(!isOpen);
|
|
65
|
+
};
|
|
66
|
+
const { pathname } = useMdUrl();
|
|
67
|
+
const t = useI18n();
|
|
68
|
+
const items = useMemo(()=>{
|
|
69
|
+
const fullMarkdownUrl = "u" > typeof window ? new URL(pathname, window.location.origin).toString() : 'loading';
|
|
70
|
+
const q = `Read ${fullMarkdownUrl}, I want to ask questions about it.`;
|
|
71
|
+
return {
|
|
72
|
+
markdownLink: {
|
|
73
|
+
title: t('copyMarkdownLinkText'),
|
|
74
|
+
icon: /*#__PURE__*/ jsx("svg", {
|
|
75
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
76
|
+
viewBox: "0 0 24 24",
|
|
77
|
+
width: "24",
|
|
78
|
+
height: "24",
|
|
79
|
+
children: /*#__PURE__*/ jsxs("g", {
|
|
80
|
+
fill: "none",
|
|
81
|
+
stroke: "currentColor",
|
|
82
|
+
strokeLinecap: "round",
|
|
83
|
+
strokeLinejoin: "round",
|
|
84
|
+
strokeWidth: "2",
|
|
85
|
+
children: [
|
|
86
|
+
/*#__PURE__*/ jsx("path", {
|
|
87
|
+
d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"
|
|
88
|
+
}),
|
|
89
|
+
/*#__PURE__*/ jsx("path", {
|
|
90
|
+
d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"
|
|
91
|
+
})
|
|
92
|
+
]
|
|
93
|
+
})
|
|
94
|
+
}),
|
|
95
|
+
onClick: ()=>{
|
|
96
|
+
navigator.clipboard.writeText(fullMarkdownUrl);
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
chatgpt: {
|
|
100
|
+
title: t('openInText', {
|
|
101
|
+
name: 'ChatGPT'
|
|
102
|
+
}),
|
|
103
|
+
href: `https://chatgpt.com/?${new URLSearchParams({
|
|
104
|
+
hints: 'search',
|
|
105
|
+
q
|
|
106
|
+
})}`,
|
|
107
|
+
icon: /*#__PURE__*/ jsxs("svg", {
|
|
108
|
+
role: "img",
|
|
109
|
+
viewBox: "0 0 24 24",
|
|
110
|
+
fill: "currentColor",
|
|
111
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
112
|
+
children: [
|
|
113
|
+
/*#__PURE__*/ jsx("title", {
|
|
114
|
+
children: "OpenAI"
|
|
115
|
+
}),
|
|
116
|
+
/*#__PURE__*/ jsx("path", {
|
|
117
|
+
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"
|
|
118
|
+
}),
|
|
119
|
+
/*#__PURE__*/ jsx("path", {
|
|
120
|
+
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"
|
|
121
|
+
})
|
|
122
|
+
]
|
|
123
|
+
})
|
|
124
|
+
},
|
|
125
|
+
claude: {
|
|
126
|
+
title: t('openInText', {
|
|
127
|
+
name: 'Claude'
|
|
128
|
+
}),
|
|
129
|
+
href: `https://claude.ai/new?${new URLSearchParams({
|
|
130
|
+
q
|
|
131
|
+
})}`,
|
|
132
|
+
icon: /*#__PURE__*/ jsxs("svg", {
|
|
133
|
+
fill: "currentColor",
|
|
134
|
+
role: "img",
|
|
135
|
+
viewBox: "0 0 24 24",
|
|
136
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
137
|
+
children: [
|
|
138
|
+
/*#__PURE__*/ jsx("title", {
|
|
139
|
+
children: "Anthropic"
|
|
140
|
+
}),
|
|
141
|
+
/*#__PURE__*/ jsx("path", {
|
|
142
|
+
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"
|
|
143
|
+
})
|
|
144
|
+
]
|
|
145
|
+
})
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
}, [
|
|
149
|
+
pathname,
|
|
150
|
+
t
|
|
151
|
+
]);
|
|
152
|
+
return /*#__PURE__*/ jsx(Fragment, {
|
|
153
|
+
children: /*#__PURE__*/ jsxs("button", {
|
|
154
|
+
ref: dropdownRef,
|
|
155
|
+
onClick: toggleDropdown,
|
|
156
|
+
className: `rp-llms-button rp-llms-view-options__trigger ${isOpen ? 'rp-llms-view-options__trigger--active' : ''}`,
|
|
157
|
+
children: [
|
|
158
|
+
/*#__PURE__*/ jsx(IconDown, {
|
|
159
|
+
className: `rp-llms-view-options__arrow ${isOpen ? 'rp-llms-view-options__arrow--rotated' : ''}`
|
|
160
|
+
}),
|
|
161
|
+
isOpen && /*#__PURE__*/ jsx("div", {
|
|
162
|
+
className: "rp-llms-view-options__menu",
|
|
163
|
+
children: options.map((item)=>{
|
|
164
|
+
let displayItem = item;
|
|
165
|
+
if ('markdownLink' === item) displayItem = items.markdownLink;
|
|
166
|
+
else if ('chatgpt' === item) displayItem = items.chatgpt;
|
|
167
|
+
else if ('claude' === item) displayItem = items.claude;
|
|
168
|
+
if (displayItem.href) return /*#__PURE__*/ jsxs("a", {
|
|
169
|
+
className: "rp-llms-view-options__menu-item",
|
|
170
|
+
href: displayItem.href,
|
|
171
|
+
target: "_blank",
|
|
172
|
+
rel: "noopener noreferrer",
|
|
173
|
+
children: [
|
|
174
|
+
/*#__PURE__*/ jsx("span", {
|
|
175
|
+
className: "rp-llms-view-options__item-icon",
|
|
176
|
+
children: displayItem.icon
|
|
177
|
+
}),
|
|
178
|
+
/*#__PURE__*/ jsx("span", {
|
|
179
|
+
children: displayItem.title
|
|
180
|
+
}),
|
|
181
|
+
/*#__PURE__*/ jsx("span", {
|
|
182
|
+
className: "rp-llms-view-options__external-icon",
|
|
183
|
+
children: /*#__PURE__*/ jsx(IconExternalLink, {})
|
|
184
|
+
})
|
|
185
|
+
]
|
|
186
|
+
}, displayItem.title);
|
|
187
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
188
|
+
className: "rp-llms-view-options__menu-item",
|
|
189
|
+
onClick: displayItem.onClick,
|
|
190
|
+
children: [
|
|
191
|
+
/*#__PURE__*/ jsx("span", {
|
|
192
|
+
className: "rp-llms-view-options__item-icon",
|
|
193
|
+
children: displayItem.icon
|
|
194
|
+
}),
|
|
195
|
+
/*#__PURE__*/ jsx("span", {
|
|
196
|
+
children: displayItem.title
|
|
197
|
+
})
|
|
198
|
+
]
|
|
199
|
+
}, displayItem.title);
|
|
200
|
+
})
|
|
201
|
+
})
|
|
202
|
+
]
|
|
203
|
+
})
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
export { LlmsViewOptions };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
.rp-llms-button {
|
|
2
|
+
border: 1px solid var(--rp-c-divider-light);
|
|
3
|
+
background: var(--rp-c-bg);
|
|
4
|
+
height: 36px;
|
|
5
|
+
color: var(--rp-c-text-2);
|
|
6
|
+
user-select: none;
|
|
7
|
+
white-space: nowrap;
|
|
8
|
+
cursor: pointer;
|
|
9
|
+
border-radius: 8px;
|
|
10
|
+
justify-content: center;
|
|
11
|
+
align-items: center;
|
|
12
|
+
gap: 6px;
|
|
13
|
+
padding: 0 12px;
|
|
14
|
+
font-size: 14px;
|
|
15
|
+
font-weight: 500;
|
|
16
|
+
line-height: normal;
|
|
17
|
+
transition: background .2s, border-color .2s, color .2s, box-shadow .2s, transform .1s, opacity .2s;
|
|
18
|
+
display: inline-flex;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.rp-llms-button:hover {
|
|
22
|
+
background: var(--rp-c-bg-soft);
|
|
23
|
+
border-color: var(--rp-c-divider);
|
|
24
|
+
color: var(--rp-c-text-1);
|
|
25
|
+
box-shadow: 0 2px 6px #0000000a;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.rp-llms-button:active {
|
|
29
|
+
background: var(--rp-c-bg-soft);
|
|
30
|
+
box-shadow: none;
|
|
31
|
+
}
|
|
32
|
+
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { LlmsContainer, type LlmsContainerProps } from './LlmsContainer.js';
|
|
2
|
+
export { LlmsCopyButton, type LlmsCopyButtonProps } from './LlmsCopyButton.js';
|
|
3
|
+
export { LlmsViewOptions, type LlmsViewOptionsProps } from './LlmsViewOptions.js';
|
|
4
|
+
export { useMdUrl } from './useMdUrl.js';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { LlmsContainer } from "./LlmsContainer.js";
|
|
2
|
+
import { LlmsCopyButton } from "./LlmsCopyButton.js";
|
|
3
|
+
import { LlmsViewOptions } from "./LlmsViewOptions.js";
|
|
4
|
+
import { useMdUrl } from "./useMdUrl.js";
|
|
5
|
+
export { LlmsContainer, LlmsCopyButton, LlmsViewOptions, useMdUrl };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { routePathToMdPath, usePageData } from "@rspress/core/runtime";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
function useMdUrl() {
|
|
4
|
+
const { page } = usePageData();
|
|
5
|
+
const mdPath = useMemo(()=>{
|
|
6
|
+
const pathname = routePathToMdPath(page.routePath);
|
|
7
|
+
return {
|
|
8
|
+
pathname
|
|
9
|
+
};
|
|
10
|
+
}, [
|
|
11
|
+
page.routePath
|
|
12
|
+
]);
|
|
13
|
+
return mdPath;
|
|
14
|
+
}
|
|
15
|
+
export { useMdUrl };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useNav } from "@rspress/core/runtime";
|
|
3
|
-
import { NavHamburger, Search, SocialLinks, SwitchAppearance } from "@theme";
|
|
3
|
+
import { NavHamburger, NavTitle, Search, SocialLinks, SwitchAppearance } from "@theme";
|
|
4
4
|
import "./index.css";
|
|
5
5
|
import { NavLangs, NavMenu, NavMenuDivider, NavVersions } from "./NavMenu.js";
|
|
6
|
-
import { NavTitle } from "./NavTitle.js";
|
|
7
6
|
function Nav(props) {
|
|
8
7
|
const { beforeNavTitle, afterNavTitle, beforeNavMenu, afterNavMenu, navTitle } = props;
|
|
9
8
|
const navList = useNav();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import './
|
|
1
|
+
import './index.scss';
|
|
2
2
|
export declare const NavTitle: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { addLeadingSlash, normalizeImagePath,
|
|
2
|
+
import { addLeadingSlash, addTrailingSlash, normalizeImagePath, useLang, useSite } from "@rspress/core/runtime";
|
|
3
3
|
import { Link } from "@theme";
|
|
4
4
|
import { useMemo } from "react";
|
|
5
|
-
import "./
|
|
5
|
+
import "./index.css";
|
|
6
6
|
const NavTitle = ()=>{
|
|
7
7
|
const { site } = useSite();
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
8
|
+
const lang = useLang();
|
|
9
|
+
const themeConfig = site?.themeConfig ?? {};
|
|
10
|
+
const defaultLang = site.lang ?? '';
|
|
11
|
+
const locales = themeConfig?.locales;
|
|
12
|
+
const localeInfo = locales?.find((locale)=>locale.lang === lang);
|
|
13
|
+
const title = (localeInfo?.title ?? site.title) || 'Home';
|
|
14
|
+
const langRoutePrefix = lang === defaultLang ? '/' : addTrailingSlash(lang);
|
|
15
|
+
const { logo: rawLogo, logoText, logoHref } = site;
|
|
11
16
|
const logo = useMemo(()=>{
|
|
12
17
|
if (!rawLogo) return null;
|
|
13
18
|
if ('string' == typeof rawLogo) return /*#__PURE__*/ jsx("img", {
|
|
@@ -38,7 +43,7 @@ const NavTitle = ()=>{
|
|
|
38
43
|
return /*#__PURE__*/ jsx("div", {
|
|
39
44
|
className: "rp-nav__title",
|
|
40
45
|
children: /*#__PURE__*/ jsxs(Link, {
|
|
41
|
-
href: addLeadingSlash(
|
|
46
|
+
href: logoHref || addLeadingSlash(langRoutePrefix),
|
|
42
47
|
className: "rp-nav__title__link",
|
|
43
48
|
children: [
|
|
44
49
|
logo && /*#__PURE__*/ jsx("div", {
|
|
@@ -27,7 +27,7 @@ body[data-page-tabs-active-index="0"] .rp-page-tabs__label__item[data-index="0"]
|
|
|
27
27
|
font-weight: 700;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
.rp-page-tabs__content__item
|
|
30
|
+
.rp-page-tabs__content__item h2:first-of-type:before, .rp-page-tabs__content__item {
|
|
31
31
|
display: none;
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -25,15 +25,15 @@
|
|
|
25
25
|
display: flex;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
.rp-tabs__label--no-scrollbar::-webkit-scrollbar {
|
|
29
|
+
display: none;
|
|
30
|
+
}
|
|
31
|
+
|
|
28
32
|
.rp-tabs__label--no-scrollbar {
|
|
29
33
|
-ms-overflow-style: none;
|
|
30
34
|
scrollbar-width: none;
|
|
31
35
|
}
|
|
32
36
|
|
|
33
|
-
.rp-tabs__label--no-scrollbar::-webkit-scrollbar {
|
|
34
|
-
display: none;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
37
|
.rp-tabs__label__item {
|
|
38
38
|
word-break: keep-all;
|
|
39
39
|
color: var(--rp-c-text-2);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { usePage } from "@rspress/core/runtime";
|
|
1
2
|
import { useCallback, useEffect, useState } from "react";
|
|
2
3
|
import { processTitleElement } from "./processTitleElement.js";
|
|
3
4
|
const updateFns = {};
|
|
@@ -38,8 +39,9 @@ function isElementVisible(element) {
|
|
|
38
39
|
return true;
|
|
39
40
|
}
|
|
40
41
|
const useDynamicToc = ()=>{
|
|
42
|
+
const { page: { toc = [] } } = usePage();
|
|
41
43
|
useSubScribe();
|
|
42
|
-
return headers.current;
|
|
44
|
+
return headers.current.length > 0 ? headers.current : toc;
|
|
43
45
|
};
|
|
44
46
|
function updateHeaders(target) {
|
|
45
47
|
const collectedHeaders = [];
|
package/dist/theme/index.d.ts
CHANGED
|
@@ -21,8 +21,10 @@ 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, LlmsViewOptions, type LlmsViewOptionsProps, useMdUrl, } from './components/Llms/index.js';
|
|
24
25
|
export { Nav, type NavProps } from './components/Nav/index.js';
|
|
25
26
|
export { NavHamburger } from './components/NavHamburger/index.js';
|
|
27
|
+
export { NavTitle } from './components/NavTitle/index.js';
|
|
26
28
|
export { Outline } from './components/Outline/index.js';
|
|
27
29
|
export { Overview } from './components/Overview/index.js';
|
|
28
30
|
export { type Group, type GroupItem, OverviewGroup, } from './components/OverviewGroup/index.js';
|
package/dist/theme/index.js
CHANGED
|
@@ -20,8 +20,10 @@ import { useHoverGroup } from "./components/HoverGroup/useHoverGroup.js";
|
|
|
20
20
|
import { LastUpdated } from "./components/LastUpdated/index.js";
|
|
21
21
|
import { Link } from "./components/Link/index.js";
|
|
22
22
|
import { useLinkNavigate } from "./components/Link/useLinkNavigate.js";
|
|
23
|
+
import { LlmsContainer, LlmsCopyButton, LlmsViewOptions, useMdUrl } from "./components/Llms/index.js";
|
|
23
24
|
import { Nav } from "./components/Nav/index.js";
|
|
24
25
|
import { NavHamburger } from "./components/NavHamburger/index.js";
|
|
26
|
+
import { NavTitle } from "./components/NavTitle/index.js";
|
|
25
27
|
import { Outline } from "./components/Outline/index.js";
|
|
26
28
|
import { Overview } from "./components/Overview/index.js";
|
|
27
29
|
import { OverviewGroup } from "./components/OverviewGroup/index.js";
|
|
@@ -60,4 +62,4 @@ import { useStorageValue } from "./logic/useStorageValue.js";
|
|
|
60
62
|
import { useThemeState } from "./logic/useThemeState.js";
|
|
61
63
|
import { parseInlineMarkdownText, renderHtmlOrText, renderInlineMarkdown } from "./logic/utils.js";
|
|
62
64
|
export * from "./icons.js";
|
|
63
|
-
export { Badge, Banner, Button, Callout, CodeBlock, CodeBlockRuntime, CodeButtonGroup, DocContent, DocFooter, DocLayout, EditLink, FallbackHeading, HomeBackground, HomeFeature, HomeFooter, HomeHero, HomeLayout, HoverGroup, LastUpdated, Layout, Link, Nav, NavHamburger, NotFoundLayout, Outline, Overview, OverviewGroup, PackageManagerTabs, PageTab, PageTabs, PrevNextPage, ReadPercent, RenderType, Root, Search, SearchButton, SearchPanel, Sidebar, SidebarList, SocialLinks, SourceCode, Steps, SvgWrapper, SwitchAppearance, Tab, Tabs, Tag, Toc, getCustomMDXComponent, mergeRefs, parseInlineMarkdownText, renderHtmlOrText, renderInlineMarkdown, useActiveAnchor, useCodeButtonGroup, useDynamicToc, useEditLink, useFullTextSearch, useHoverGroup, useLinkNavigate, usePrevNextPage, useRedirect4FirstVisit, useScrollAfterNav, useScrollReset, useSetup, useStorageValue, useThemeState, useWatchToc };
|
|
65
|
+
export { Badge, Banner, Button, Callout, CodeBlock, CodeBlockRuntime, CodeButtonGroup, DocContent, DocFooter, DocLayout, EditLink, FallbackHeading, HomeBackground, HomeFeature, HomeFooter, HomeHero, HomeLayout, HoverGroup, LastUpdated, Layout, Link, LlmsContainer, LlmsCopyButton, LlmsViewOptions, Nav, NavHamburger, NavTitle, NotFoundLayout, Outline, Overview, OverviewGroup, PackageManagerTabs, PageTab, PageTabs, PrevNextPage, ReadPercent, RenderType, Root, Search, SearchButton, SearchPanel, Sidebar, SidebarList, SocialLinks, SourceCode, Steps, SvgWrapper, SwitchAppearance, Tab, Tabs, Tag, Toc, getCustomMDXComponent, mergeRefs, parseInlineMarkdownText, renderHtmlOrText, renderInlineMarkdown, useActiveAnchor, useCodeButtonGroup, useDynamicToc, useEditLink, useFullTextSearch, useHoverGroup, useLinkNavigate, useMdUrl, usePrevNextPage, useRedirect4FirstVisit, useScrollAfterNav, useScrollReset, useSetup, useStorageValue, useThemeState, useWatchToc };
|
|
@@ -71,7 +71,7 @@ function Layout(props) {
|
|
|
71
71
|
let title = frontmatter.title ?? articleTitle;
|
|
72
72
|
const mainTitle = site.title || localesData.title || '';
|
|
73
73
|
title = title && ('doc' === pageType || 'doc-wide' === pageType) ? concatTitle(title, frontmatter.titleSuffix || mainTitle) : 'home' === pageType ? concatTitle(mainTitle, frontmatter.titleSuffix) : '404' === pageType ? concatTitle('404', mainTitle) : mainTitle;
|
|
74
|
-
const description =
|
|
74
|
+
const description = page.description || site.description || localesData.description;
|
|
75
75
|
const getContentLayout = ()=>{
|
|
76
76
|
switch(pageType){
|
|
77
77
|
case 'home':
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspress/core",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.6",
|
|
4
4
|
"description": "The Rspress Documentation Framework",
|
|
5
5
|
"bugs": "https://github.com/web-infra-dev/rspress/issues",
|
|
6
6
|
"repository": {
|
|
@@ -63,12 +63,11 @@
|
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@mdx-js/mdx": "^3.1.1",
|
|
65
65
|
"@mdx-js/react": "^3.1.1",
|
|
66
|
-
"@rsbuild/core": "~1.7.
|
|
67
|
-
"@rsbuild/plugin-react": "~1.4.
|
|
68
|
-
"@
|
|
69
|
-
"@shikijs/rehype": "^3.20.0",
|
|
66
|
+
"@rsbuild/core": "~1.7.2",
|
|
67
|
+
"@rsbuild/plugin-react": "~1.4.3",
|
|
68
|
+
"@shikijs/rehype": "^3.21.0",
|
|
70
69
|
"@types/unist": "^3.0.3",
|
|
71
|
-
"@unhead/react": "^2.1.
|
|
70
|
+
"@unhead/react": "^2.1.2",
|
|
72
71
|
"body-scroll-lock": "4.0.0-beta.0",
|
|
73
72
|
"cac": "^6.7.14",
|
|
74
73
|
"chokidar": "^3.6.0",
|
|
@@ -78,7 +77,6 @@
|
|
|
78
77
|
"github-slugger": "^2.0.0",
|
|
79
78
|
"hast-util-heading-rank": "^3.0.0",
|
|
80
79
|
"hast-util-to-jsx-runtime": "^2.3.6",
|
|
81
|
-
"html-to-text": "^9.0.5",
|
|
82
80
|
"lodash-es": "^4.17.22",
|
|
83
81
|
"mdast-util-mdx": "^3.0.0",
|
|
84
82
|
"mdast-util-mdxjs-esm": "^2.0.1",
|
|
@@ -89,37 +87,38 @@
|
|
|
89
87
|
"react-dom": "^19.2.3",
|
|
90
88
|
"react-lazy-with-preload": "^2.2.1",
|
|
91
89
|
"react-reconciler": "0.33.0",
|
|
92
|
-
"react-router-dom": "^7.
|
|
90
|
+
"react-router-dom": "^7.12.0",
|
|
93
91
|
"rehype-external-links": "^3.0.0",
|
|
94
92
|
"rehype-raw": "^7.0.0",
|
|
95
93
|
"remark-gfm": "^4.0.1",
|
|
96
94
|
"remark-mdx": "^3.1.1",
|
|
95
|
+
"remark-parse": "^11.0.0",
|
|
97
96
|
"remark-stringify": "^11.0.0",
|
|
98
97
|
"scroll-into-view-if-needed": "^3.1.0",
|
|
99
|
-
"shiki": "^3.
|
|
98
|
+
"shiki": "^3.21.0",
|
|
100
99
|
"tinyglobby": "^0.2.15",
|
|
101
100
|
"tinypool": "^1.1.1",
|
|
102
101
|
"unified": "^11.0.5",
|
|
102
|
+
"unist-util-remove": "^4.0.0",
|
|
103
103
|
"unist-util-visit": "^5.0.0",
|
|
104
104
|
"unist-util-visit-children": "^3.0.0",
|
|
105
|
-
"@rspress/shared": "2.0.0-rc.
|
|
105
|
+
"@rspress/shared": "2.0.0-rc.6"
|
|
106
106
|
},
|
|
107
107
|
"devDependencies": {
|
|
108
108
|
"@microsoft/api-extractor": "^7.55.2",
|
|
109
|
-
"@rsbuild/plugin-sass": "~1.4.
|
|
110
|
-
"@rsbuild/plugin-svgr": "^1.2.
|
|
111
|
-
"@rslib/core": "0.19.
|
|
109
|
+
"@rsbuild/plugin-sass": "~1.4.1",
|
|
110
|
+
"@rsbuild/plugin-svgr": "^1.2.4",
|
|
111
|
+
"@rslib/core": "0.19.2",
|
|
112
112
|
"@types/body-scroll-lock": "^3.1.2",
|
|
113
113
|
"@types/hast": "^3.0.4",
|
|
114
|
-
"@types/html-to-text": "^9.0.4",
|
|
115
114
|
"@types/lodash-es": "^4.17.12",
|
|
116
115
|
"@types/mdast": "^4.0.4",
|
|
117
116
|
"@types/node": "^22.8.1",
|
|
118
117
|
"@types/nprogress": "^0.2.3",
|
|
119
|
-
"@types/react": "^19.2.
|
|
118
|
+
"@types/react": "^19.2.8",
|
|
120
119
|
"@types/react-dom": "^19.2.3",
|
|
121
120
|
"@types/react-reconciler": "^0.32.3",
|
|
122
|
-
"@types/web": "^0.0.
|
|
121
|
+
"@types/web": "^0.0.318",
|
|
123
122
|
"execa": "8.0.1",
|
|
124
123
|
"mdast-util-directive": "^3.1.0",
|
|
125
124
|
"mdast-util-mdx-expression": "^2.0.1",
|
package/dist/8813.4b28f4bb.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { visit } from "unist-util-visit";
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|