@rspress/core 2.0.0-rc.4 → 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.723d12b2.js → 0~7675.d236b058.js} +3 -3
- package/dist/{5485.9fc7f63d.js → 5485.7586c86a.js} +1 -1
- package/dist/{3521.9eb6b114.js → 7786.421b464f.js} +2 -2
- package/dist/9348.1beb3e25.js +11 -0
- package/dist/_private/react/render.js +1 -1
- 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/CodeBlock/index.tsx +1 -1
- package/dist/eject-theme/components/DocContent/docComponents/title.tsx +21 -2
- package/dist/eject-theme/components/FallbackHeading/index.tsx +4 -0
- package/dist/eject-theme/components/HomeBackground/useNavTransparent.tsx +2 -1
- package/dist/eject-theme/components/HomeHero/index.scss +8 -0
- package/dist/eject-theme/components/HomeHero/index.tsx +11 -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/eject-theme/components/Overview/index.tsx +8 -62
- package/dist/eject-theme/components/OverviewGroup/index.tsx +46 -0
- package/dist/eject-theme/components/Steps/index.scss +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -4
- 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 +6 -6
- 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 -3
- 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 -58
- 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 -3
- 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/Content.d.ts +4 -0
- package/dist/runtime/Content.js +18 -0
- package/dist/runtime/NoSSR.d.ts +3 -0
- package/dist/runtime/NoSSR.js +14 -0
- package/dist/runtime/getSidebarDataGroup.test.js +68 -0
- package/dist/runtime/hooks/useActiveMatcher.d.ts +1 -0
- package/dist/runtime/hooks/useActiveMatcher.js +14 -0
- package/dist/runtime/hooks/useDark.d.ts +7 -0
- package/dist/runtime/hooks/useDark.js +7 -0
- package/dist/runtime/hooks/useFrontmatter.d.ts +4 -0
- package/dist/runtime/hooks/useFrontmatter.js +9 -0
- package/dist/runtime/hooks/useI18n.d.ts +2 -0
- package/dist/runtime/hooks/useI18n.js +14 -0
- package/dist/runtime/hooks/useLang.d.ts +1 -0
- package/dist/runtime/hooks/useLang.js +6 -0
- package/dist/runtime/hooks/useLocaleSiteData.d.ts +18 -0
- package/dist/runtime/hooks/useLocaleSiteData.js +20 -0
- package/dist/runtime/hooks/useNav.d.ts +1 -0
- package/dist/runtime/hooks/useNav.js +12 -0
- package/dist/runtime/hooks/usePage.d.ts +10 -0
- package/dist/runtime/hooks/usePage.js +9 -0
- package/dist/runtime/hooks/usePageData.d.ts +5 -0
- package/dist/runtime/hooks/usePageData.js +16 -0
- package/dist/runtime/hooks/usePages.d.ts +4 -0
- package/dist/runtime/hooks/usePages.js +7 -0
- package/dist/runtime/hooks/useSidebar.d.ts +16 -0
- package/dist/runtime/hooks/useSidebar.js +67 -0
- package/dist/runtime/hooks/useSite.d.ts +4 -0
- package/dist/runtime/hooks/useSite.js +7 -0
- package/dist/runtime/hooks/useVersion.d.ts +1 -0
- package/dist/runtime/hooks/useVersion.js +6 -0
- package/dist/runtime/hooks/useWindowSize.d.ts +9 -0
- package/dist/runtime/hooks/useWindowSize.js +31 -0
- package/dist/runtime/hooks/useWindowSize.test.js +36 -0
- package/dist/runtime/index.d.ts +21 -0
- package/dist/runtime/index.js +22 -0
- package/dist/runtime/route.d.ts +36 -0
- package/dist/runtime/route.js +53 -0
- package/dist/runtime/route.test.js +154 -0
- package/dist/runtime/ssrMdServerEntry.js +1 -1
- package/dist/runtime/utils.d.ts +12 -0
- package/dist/runtime/utils.js +34 -0
- package/dist/runtime/utils.test.js +34 -0
- package/dist/theme/components/Callout/index.css +6 -6
- package/dist/theme/components/CodeBlock/index.js +1 -1
- package/dist/theme/components/DocContent/docComponents/title.js +25 -5
- package/dist/theme/components/FallbackHeading/index.js +4 -1
- package/dist/theme/components/HomeBackground/useNavTransparent.js +1 -1
- package/dist/theme/components/HomeHero/index.css +16 -10
- package/dist/theme/components/HomeHero/index.js +10 -3
- 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/Overview/index.js +11 -43
- package/dist/theme/components/OverviewGroup/index.js +33 -0
- package/dist/theme/components/PageTabs/index.css +1 -1
- package/dist/theme/components/Steps/index.css +1 -0
- 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 +3 -1
- package/dist/theme/index.js +4 -2
- package/dist/theme/layout/Layout/index.js +1 -1
- package/dist/theme/logic/useScrollAfterNav.js +2 -2
- package/dist/theme/logic/useScrollReset.js +2 -2
- package/dist/theme/logic/{useAppearance.d.ts → useThemeState.d.ts} +4 -1
- package/dist/theme/logic/useThemeState.js +50 -0
- package/dist/theme/styles/scrollbar.css +14 -2
- package/package.json +18 -20
- package/static/MediumZoom.tsx +1 -1
- package/dist/4669.69cb6b18.js +0 -1
- package/dist/8813.4b28f4bb.js +0 -1
- package/dist/9643.2dff683e.js +0 -4
- package/dist/cli/config/index.d.ts +0 -2
- package/dist/runtime.72d450ac.js +0 -1
- package/dist/runtime.d.ts +0 -2
- package/dist/runtime.js +0 -3
- package/dist/theme/logic/useAppearance.js +0 -64
- /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
|
@@ -1,49 +1,10 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { isEqualPath,
|
|
2
|
+
import { isEqualPath, useI18n, usePageData, useSidebar } from "@rspress/core/runtime";
|
|
3
3
|
import { FallbackHeading, OverviewGroup } from "@theme";
|
|
4
4
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
5
5
|
import { isSidebarDivider, isSidebarSectionHeader, isSidebarSingleFile } from "../Sidebar/utils.js";
|
|
6
6
|
import "./index.css";
|
|
7
7
|
import { findItemByRoutePath } from "./utils.js";
|
|
8
|
-
function routePathToMdPath(routePath) {
|
|
9
|
-
let url = routePath;
|
|
10
|
-
url = normalizeHref(url, false);
|
|
11
|
-
url = url.replace(/\.html$/, '.md');
|
|
12
|
-
return withBase(url);
|
|
13
|
-
}
|
|
14
|
-
function OverviewMarkdown({ title, groups }) {
|
|
15
|
-
const lines = [];
|
|
16
|
-
lines.push(`# ${title}`);
|
|
17
|
-
lines.push('');
|
|
18
|
-
for (const group of groups){
|
|
19
|
-
if (group.name) {
|
|
20
|
-
lines.push(`## ${group.name}`);
|
|
21
|
-
lines.push('');
|
|
22
|
-
}
|
|
23
|
-
for (const item of group.items){
|
|
24
|
-
const itemTitle = item.link ? `[${item.text}](${routePathToMdPath(item.link)})` : `**${item.text}**`;
|
|
25
|
-
lines.push(`### ${itemTitle}`);
|
|
26
|
-
lines.push('');
|
|
27
|
-
if (item.headers && item.headers.length > 0) {
|
|
28
|
-
for (const header of item.headers){
|
|
29
|
-
const headerLink = item.link ? `[${header.text}](${routePathToMdPath(item.link)}#${header.id})` : header.text;
|
|
30
|
-
lines.push(`- ${headerLink}`);
|
|
31
|
-
}
|
|
32
|
-
lines.push('');
|
|
33
|
-
}
|
|
34
|
-
if (item.items && item.items.length > 0) {
|
|
35
|
-
for (const subItem of item.items){
|
|
36
|
-
const subItemLink = subItem.link ? `[${subItem.text}](${routePathToMdPath(subItem.link)})` : subItem.text;
|
|
37
|
-
lines.push(`- ${subItemLink}`);
|
|
38
|
-
}
|
|
39
|
-
lines.push('');
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return /*#__PURE__*/ jsx(Fragment, {
|
|
44
|
-
children: lines.join('\n')
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
8
|
const normalizeText = (s)=>s.toLowerCase().replace(/-/g, ' ');
|
|
48
9
|
const matchesQuery = (text, query)=>normalizeText(text).includes(normalizeText(query));
|
|
49
10
|
const OverviewSearchInput = ({ query, setQuery, searchRef })=>{
|
|
@@ -154,9 +115,16 @@ function Overview(props) {
|
|
|
154
115
|
query
|
|
155
116
|
]);
|
|
156
117
|
const overviewTitle = title || 'Overview';
|
|
157
|
-
if (process.env.__SSR_MD__) return /*#__PURE__*/
|
|
158
|
-
|
|
159
|
-
|
|
118
|
+
if (process.env.__SSR_MD__) return /*#__PURE__*/ jsxs(Fragment, {
|
|
119
|
+
children: [
|
|
120
|
+
/*#__PURE__*/ jsx(FallbackHeading, {
|
|
121
|
+
level: 1,
|
|
122
|
+
title: overviewTitle
|
|
123
|
+
}),
|
|
124
|
+
groups.map((group)=>/*#__PURE__*/ jsx(OverviewGroup, {
|
|
125
|
+
group: group
|
|
126
|
+
}, group?.name))
|
|
127
|
+
]
|
|
160
128
|
});
|
|
161
129
|
return /*#__PURE__*/ jsxs("div", {
|
|
162
130
|
className: "rspress-doc rp-doc rspress-overview rp-overview",
|
|
@@ -1,9 +1,42 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { FallbackHeading, Link, SvgWrapper, renderInlineMarkdown } from "@theme";
|
|
3
3
|
import "./index.css";
|
|
4
|
+
import { routePathToMdPath } from "@rspress/core/runtime";
|
|
4
5
|
import { useMemo } from "react";
|
|
5
6
|
import icons_plugin from "./icons/plugin.js";
|
|
7
|
+
function OverviewGroupMarkdown({ group }) {
|
|
8
|
+
const lines = [];
|
|
9
|
+
if (group.name) {
|
|
10
|
+
lines.push(`## ${group.name}`);
|
|
11
|
+
lines.push('');
|
|
12
|
+
}
|
|
13
|
+
for (const item of group.items){
|
|
14
|
+
const itemTitle = item.link ? `[${item.text}](${routePathToMdPath(item.link)})` : `**${item.text}**`;
|
|
15
|
+
lines.push(`### ${itemTitle}`);
|
|
16
|
+
lines.push('');
|
|
17
|
+
if (item.headers && item.headers.length > 0) {
|
|
18
|
+
for (const header of item.headers){
|
|
19
|
+
const headerLink = item.link ? `[${header.text}](${routePathToMdPath(item.link)}#${header.id})` : header.text;
|
|
20
|
+
lines.push(`- ${headerLink}`);
|
|
21
|
+
}
|
|
22
|
+
lines.push('');
|
|
23
|
+
}
|
|
24
|
+
if (item.items && item.items.length > 0) {
|
|
25
|
+
for (const subItem of item.items){
|
|
26
|
+
const subItemLink = subItem.link ? `[${subItem.text}](${routePathToMdPath(subItem.link)})` : subItem.text;
|
|
27
|
+
lines.push(`- ${subItemLink}`);
|
|
28
|
+
}
|
|
29
|
+
lines.push('');
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return /*#__PURE__*/ jsx(Fragment, {
|
|
33
|
+
children: lines.join('\n')
|
|
34
|
+
});
|
|
35
|
+
}
|
|
6
36
|
const OverviewGroup = ({ group })=>{
|
|
37
|
+
if (process.env.__SSR_MD__) return /*#__PURE__*/ jsx(OverviewGroupMarkdown, {
|
|
38
|
+
group: group
|
|
39
|
+
});
|
|
7
40
|
const { itemsWithContent, itemsWithoutContent } = useMemo(()=>{
|
|
8
41
|
const itemsWithContent = group.items.filter((item)=>item.headers && item.headers.length > 0 || item.items && item.items.length > 0);
|
|
9
42
|
const itemsWithoutContent = group.items.filter((item)=>!(item.headers && item.headers.length > 0) && !(item.items && item.items.length > 0));
|
|
@@ -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';
|
|
@@ -53,7 +55,6 @@ export { HomeLayout, type HomeLayoutProps } from './layout/HomeLayout/index.js';
|
|
|
53
55
|
export { Layout, type LayoutProps } from './layout/Layout/index.js';
|
|
54
56
|
export { NotFoundLayout } from './layout/NotFountLayout/index.js';
|
|
55
57
|
export { mergeRefs } from './logic/mergeRefs.js';
|
|
56
|
-
export { useThemeState } from './logic/useAppearance.js';
|
|
57
58
|
export { useFullTextSearch } from './logic/useFullTextSearch.js';
|
|
58
59
|
export { usePrevNextPage } from './logic/usePrevNextPage.js';
|
|
59
60
|
export { useRedirect4FirstVisit } from './logic/useRedirect4FirstVisit.js';
|
|
@@ -61,4 +62,5 @@ export { useScrollAfterNav } from './logic/useScrollAfterNav.js';
|
|
|
61
62
|
export { useScrollReset } from './logic/useScrollReset.js';
|
|
62
63
|
export { useSetup } from './logic/useSetup.js';
|
|
63
64
|
export { useStorageValue } from './logic/useStorageValue.js';
|
|
65
|
+
export { useThemeState } from './logic/useThemeState.js';
|
|
64
66
|
export { parseInlineMarkdownText, renderHtmlOrText, renderInlineMarkdown, } from './logic/utils.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";
|
|
@@ -50,7 +52,6 @@ import { HomeLayout } from "./layout/HomeLayout/index.js";
|
|
|
50
52
|
import { Layout } from "./layout/Layout/index.js";
|
|
51
53
|
import { NotFoundLayout } from "./layout/NotFountLayout/index.js";
|
|
52
54
|
import { mergeRefs } from "./logic/mergeRefs.js";
|
|
53
|
-
import { useThemeState } from "./logic/useAppearance.js";
|
|
54
55
|
import { useFullTextSearch } from "./logic/useFullTextSearch.js";
|
|
55
56
|
import { usePrevNextPage } from "./logic/usePrevNextPage.js";
|
|
56
57
|
import { useRedirect4FirstVisit } from "./logic/useRedirect4FirstVisit.js";
|
|
@@ -58,6 +59,7 @@ import { useScrollAfterNav } from "./logic/useScrollAfterNav.js";
|
|
|
58
59
|
import { useScrollReset } from "./logic/useScrollReset.js";
|
|
59
60
|
import { useSetup } from "./logic/useSetup.js";
|
|
60
61
|
import { useStorageValue } from "./logic/useStorageValue.js";
|
|
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':
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useLocation } from "@rspress/core/runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useLayoutEffect } from "react";
|
|
3
3
|
function parseCSSLength(value) {
|
|
4
4
|
if (!value || 'auto' === value || 'none' === value) return 0;
|
|
5
5
|
const numValue = Number.parseFloat(value);
|
|
@@ -20,7 +20,7 @@ function scrollToTarget(target) {
|
|
|
20
20
|
}
|
|
21
21
|
function useScrollAfterNav() {
|
|
22
22
|
const location = useLocation();
|
|
23
|
-
|
|
23
|
+
useLayoutEffect(()=>{
|
|
24
24
|
const decodedHash = decodeURIComponent(window.location.hash);
|
|
25
25
|
if (decodedHash.length > 0) {
|
|
26
26
|
const target = document.getElementById(decodedHash.slice(1));
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useLayoutEffect } from "react";
|
|
2
2
|
import { useLocation } from "react-router-dom";
|
|
3
3
|
function useScrollReset() {
|
|
4
4
|
const { pathname } = useLocation();
|
|
5
|
-
|
|
5
|
+
useLayoutEffect(()=>{
|
|
6
6
|
const decodedHash = decodeURIComponent(window.location.hash);
|
|
7
7
|
if (0 === decodedHash.length) window.scrollTo(0, 0);
|
|
8
8
|
}, [
|
|
@@ -4,10 +4,13 @@ declare global {
|
|
|
4
4
|
RSPRESS_THEME?: string;
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
|
+
/** Resolved theme value used in the app */
|
|
7
8
|
type ThemeValue = 'light' | 'dark';
|
|
9
|
+
/** Theme config value stored in localStorage */
|
|
8
10
|
type ThemeConfigValue = ThemeValue | 'auto';
|
|
9
11
|
/**
|
|
10
12
|
* State provider for theme context.
|
|
13
|
+
* @internal
|
|
11
14
|
*/
|
|
12
|
-
export declare
|
|
15
|
+
export declare function useThemeState(): readonly [ThemeValue, (value: ThemeValue, storeValue?: ThemeConfigValue) => void];
|
|
13
16
|
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useSite } from "@rspress/core/runtime";
|
|
2
|
+
import { useCallback, useLayoutEffect, useMemo } from "react";
|
|
3
|
+
import { useMediaQuery } from "./useMediaQuery.js";
|
|
4
|
+
import { useStorageValue } from "./useStorageValue.js";
|
|
5
|
+
const APPEARANCE_KEY = 'rspress-theme-appearance';
|
|
6
|
+
const MEDIA_QUERY = '(prefers-color-scheme: dark)';
|
|
7
|
+
const applyThemeToDOM = (theme)=>{
|
|
8
|
+
if (!document || !document.documentElement) return;
|
|
9
|
+
const root = document.documentElement;
|
|
10
|
+
root.classList.toggle('dark', 'dark' === theme);
|
|
11
|
+
root.classList.toggle('rp-dark', 'dark' === theme);
|
|
12
|
+
root.style.colorScheme = theme;
|
|
13
|
+
};
|
|
14
|
+
function useThemeState() {
|
|
15
|
+
const { site } = useSite();
|
|
16
|
+
const disableDarkMode = false === site.themeConfig.darkMode;
|
|
17
|
+
const prefersDark = useMediaQuery(MEDIA_QUERY);
|
|
18
|
+
const [storedConfig, setStoredConfig] = useStorageValue(APPEARANCE_KEY, 'auto');
|
|
19
|
+
const resolvedTheme = useMemo(()=>{
|
|
20
|
+
if ("u" < typeof window) return 'light';
|
|
21
|
+
if (disableDarkMode) return 'light';
|
|
22
|
+
const defaultTheme = window.RSPRESS_THEME;
|
|
23
|
+
if (defaultTheme) return 'dark' === defaultTheme ? 'dark' : 'light';
|
|
24
|
+
return 'auto' === storedConfig ? prefersDark ? 'dark' : 'light' : storedConfig;
|
|
25
|
+
}, [
|
|
26
|
+
disableDarkMode,
|
|
27
|
+
prefersDark,
|
|
28
|
+
storedConfig
|
|
29
|
+
]);
|
|
30
|
+
const setTheme = useCallback((value, storeValue = value)=>{
|
|
31
|
+
if (disableDarkMode) return;
|
|
32
|
+
setStoredConfig(storeValue);
|
|
33
|
+
applyThemeToDOM(value);
|
|
34
|
+
}, [
|
|
35
|
+
disableDarkMode,
|
|
36
|
+
setStoredConfig
|
|
37
|
+
]);
|
|
38
|
+
useLayoutEffect(()=>{
|
|
39
|
+
if (disableDarkMode) return;
|
|
40
|
+
applyThemeToDOM(resolvedTheme);
|
|
41
|
+
}, [
|
|
42
|
+
disableDarkMode,
|
|
43
|
+
resolvedTheme
|
|
44
|
+
]);
|
|
45
|
+
return [
|
|
46
|
+
resolvedTheme,
|
|
47
|
+
setTheme
|
|
48
|
+
];
|
|
49
|
+
}
|
|
50
|
+
export { useThemeState };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
.rp-scrollbar {
|
|
2
2
|
scrollbar-gutter: stable;
|
|
3
|
+
scrollbar-width: thin;
|
|
4
|
+
scrollbar-color: #0000000d #0000;
|
|
3
5
|
}
|
|
4
6
|
|
|
5
7
|
.rp-scrollbar::-webkit-scrollbar {
|
|
@@ -17,7 +19,7 @@
|
|
|
17
19
|
transition: background .2s;
|
|
18
20
|
}
|
|
19
21
|
|
|
20
|
-
.rp-scrollbar
|
|
22
|
+
.rp-scrollbar::-webkit-scrollbar-thumb:hover {
|
|
21
23
|
background: #0000001a;
|
|
22
24
|
}
|
|
23
25
|
|
|
@@ -25,11 +27,21 @@
|
|
|
25
27
|
background: none;
|
|
26
28
|
}
|
|
27
29
|
|
|
30
|
+
.rp-dark .rp-scrollbar {
|
|
31
|
+
scrollbar-color: #ffffff1a #0000;
|
|
32
|
+
}
|
|
33
|
+
|
|
28
34
|
.rp-dark .rp-scrollbar::-webkit-scrollbar-thumb {
|
|
29
35
|
background: #ffffff1a;
|
|
30
36
|
}
|
|
31
37
|
|
|
32
|
-
.rp-dark .rp-scrollbar
|
|
38
|
+
.rp-dark .rp-scrollbar::-webkit-scrollbar-thumb:hover {
|
|
33
39
|
background: #fff3;
|
|
34
40
|
}
|
|
35
41
|
|
|
42
|
+
.rp-scrollbar--always {
|
|
43
|
+
scrollbar-gutter: stable;
|
|
44
|
+
scrollbar-width: unset;
|
|
45
|
+
scrollbar-color: unset;
|
|
46
|
+
}
|
|
47
|
+
|
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": {
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"default": "./dist/theme/index.js"
|
|
36
36
|
},
|
|
37
37
|
"./runtime": {
|
|
38
|
-
"types": "./dist/runtime.d.ts",
|
|
39
|
-
"default": "./dist/runtime.js"
|
|
38
|
+
"types": "./dist/runtime/index.d.ts",
|
|
39
|
+
"default": "./dist/runtime/index.js"
|
|
40
40
|
},
|
|
41
41
|
"./shiki-transformers": {
|
|
42
42
|
"types": "./dist/shiki-transformers.d.ts",
|
|
@@ -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.
|
|
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.
|
|
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,38 +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/
|
|
106
|
-
"@rspress/shared": "2.0.0-rc.4"
|
|
105
|
+
"@rspress/shared": "2.0.0-rc.6"
|
|
107
106
|
},
|
|
108
107
|
"devDependencies": {
|
|
109
108
|
"@microsoft/api-extractor": "^7.55.2",
|
|
110
|
-
"@rsbuild/plugin-sass": "~1.4.
|
|
111
|
-
"@rsbuild/plugin-svgr": "^1.2.
|
|
112
|
-
"@rslib/core": "0.
|
|
109
|
+
"@rsbuild/plugin-sass": "~1.4.1",
|
|
110
|
+
"@rsbuild/plugin-svgr": "^1.2.4",
|
|
111
|
+
"@rslib/core": "0.19.2",
|
|
113
112
|
"@types/body-scroll-lock": "^3.1.2",
|
|
114
113
|
"@types/hast": "^3.0.4",
|
|
115
|
-
"@types/html-to-text": "^9.0.4",
|
|
116
114
|
"@types/lodash-es": "^4.17.12",
|
|
117
115
|
"@types/mdast": "^4.0.4",
|
|
118
116
|
"@types/node": "^22.8.1",
|
|
119
117
|
"@types/nprogress": "^0.2.3",
|
|
120
|
-
"@types/react": "^19.2.
|
|
118
|
+
"@types/react": "^19.2.8",
|
|
121
119
|
"@types/react-dom": "^19.2.3",
|
|
122
120
|
"@types/react-reconciler": "^0.32.3",
|
|
123
|
-
"@types/web": "^0.0.
|
|
121
|
+
"@types/web": "^0.0.318",
|
|
124
122
|
"execa": "8.0.1",
|
|
125
123
|
"mdast-util-directive": "^3.1.0",
|
|
126
124
|
"mdast-util-mdx-expression": "^2.0.1",
|
|
@@ -144,7 +142,7 @@
|
|
|
144
142
|
"registry": "https://registry.npmjs.org/"
|
|
145
143
|
},
|
|
146
144
|
"scripts": {
|
|
147
|
-
"build": "rslib build",
|
|
145
|
+
"build": "node ./scripts/generateJsonSchema.mjs && rslib build",
|
|
148
146
|
"dev": "rslib build -w",
|
|
149
147
|
"reset": "rimraf ./**/node_modules"
|
|
150
148
|
}
|
package/static/MediumZoom.tsx
CHANGED
package/dist/4669.69cb6b18.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { MDX_OR_MD_REGEXP, RSPRESS_TEMP_DIR, SEARCH_INDEX_NAME, addLeadingSlash, addTrailingSlash, getSidebarDataGroup, isDataUrl, isDebugMode, isExternalUrl, isProduction, matchNavbar, matchSidebar, normalizeHref, normalizePosixPath, parseUrl, removeLeadingSlash, removeTrailingSlash, slash, withBase } from "@rspress/shared";
|
package/dist/8813.4b28f4bb.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { visit } from "unist-util-visit";
|
package/dist/9643.2dff683e.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export { extractTextAndId, getIconUrlPath, getNodeAttribute, loadFrontMatter, mergeDocConfig } from "@rspress/shared/node-utils";
|
|
2
|
-
export { constants, default as node_os } from "node:os";
|
|
3
|
-
export { cwd, default as node_process } from "node:process";
|
|
4
|
-
export { createProcessor, nodeTypes } from "@mdx-js/mdx";
|
package/dist/runtime.72d450ac.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "@rspress/runtime";
|
package/dist/runtime.d.ts
DELETED
package/dist/runtime.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { useSite } from "@rspress/core/runtime";
|
|
2
|
-
import { useCallback, useEffect, useState } from "react";
|
|
3
|
-
import { useHandler } from "./useHandler.js";
|
|
4
|
-
import { useMediaQuery } from "./useMediaQuery.js";
|
|
5
|
-
import { useStorageValue } from "./useStorageValue.js";
|
|
6
|
-
const APPEARANCE_KEY = 'rspress-theme-appearance';
|
|
7
|
-
const sanitize = (value)=>[
|
|
8
|
-
'light',
|
|
9
|
-
'dark',
|
|
10
|
-
'auto'
|
|
11
|
-
].includes(value) ? value : 'auto';
|
|
12
|
-
const useThemeState = ()=>{
|
|
13
|
-
const matchesDark = useMediaQuery('(prefers-color-scheme: dark)');
|
|
14
|
-
const [storedTheme, setStoredTheme] = useStorageValue(APPEARANCE_KEY, 'auto');
|
|
15
|
-
const { site } = useSite();
|
|
16
|
-
const disableDarkMode = false === site.themeConfig.darkMode;
|
|
17
|
-
const getPreferredTheme = useHandler(()=>{
|
|
18
|
-
if (disableDarkMode) return 'light';
|
|
19
|
-
const sanitized = sanitize(storedTheme);
|
|
20
|
-
return 'auto' === sanitized ? matchesDark ? 'dark' : 'light' : sanitized;
|
|
21
|
-
});
|
|
22
|
-
const [theme, setThemeInternal] = useState(()=>{
|
|
23
|
-
if ("u" < typeof window) return 'light';
|
|
24
|
-
const defaultTheme = window.RSPRESS_THEME ?? window.MODERN_THEME;
|
|
25
|
-
if (defaultTheme) return 'dark' === defaultTheme ? 'dark' : 'light';
|
|
26
|
-
return getPreferredTheme();
|
|
27
|
-
});
|
|
28
|
-
const setTheme = useCallback((value, storeValue = value)=>{
|
|
29
|
-
if (disableDarkMode) return;
|
|
30
|
-
setThemeInternal(value);
|
|
31
|
-
setStoredTheme(storeValue);
|
|
32
|
-
setSkipEffect(true);
|
|
33
|
-
}, []);
|
|
34
|
-
useEffect(()=>{
|
|
35
|
-
document.documentElement.classList.toggle('dark', 'dark' === theme);
|
|
36
|
-
document.documentElement.classList.toggle('rp-dark', 'dark' === theme);
|
|
37
|
-
document.documentElement.style.colorScheme = theme;
|
|
38
|
-
}, [
|
|
39
|
-
theme
|
|
40
|
-
]);
|
|
41
|
-
const [skipEffect, setSkipEffect] = useState(true);
|
|
42
|
-
useEffect(()=>{
|
|
43
|
-
setSkipEffect(false);
|
|
44
|
-
}, [
|
|
45
|
-
skipEffect
|
|
46
|
-
]);
|
|
47
|
-
useEffect(()=>{
|
|
48
|
-
if (skipEffect) return;
|
|
49
|
-
setTheme(getPreferredTheme(), sanitize(storedTheme));
|
|
50
|
-
}, [
|
|
51
|
-
storedTheme
|
|
52
|
-
]);
|
|
53
|
-
useEffect(()=>{
|
|
54
|
-
if (skipEffect) return;
|
|
55
|
-
setTheme(matchesDark ? 'dark' : 'light', 'auto');
|
|
56
|
-
}, [
|
|
57
|
-
matchesDark
|
|
58
|
-
]);
|
|
59
|
-
return [
|
|
60
|
-
theme,
|
|
61
|
-
setTheme
|
|
62
|
-
];
|
|
63
|
-
};
|
|
64
|
-
export { useThemeState };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|