@rspress/core 2.0.0-rc.2 → 2.0.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{0~7675.989ee664.js → 0~7675.723d12b2.js} +18 -15
- package/dist/{5313.6594aba0.js → 3521.9eb6b114.js} +12 -19
- package/dist/4669.69cb6b18.js +1 -0
- package/dist/{5485.2a0273cf.js → 5485.9fc7f63d.js} +5 -5
- package/dist/6289.29817fb4.js +4 -0
- package/dist/8813.4b28f4bb.js +1 -0
- package/dist/9643.2dff683e.js +4 -0
- package/dist/_private/react/render.js +17 -4
- package/dist/cli/config/loadConfigFile.js +2 -2
- package/dist/cli/index.44f3184c.js +2 -0
- package/dist/cli/index.js +3 -3
- package/dist/eject-theme/components/Badge/index.scss +1 -0
- package/dist/eject-theme/components/Banner/index.tsx +3 -1
- package/dist/eject-theme/components/Callout/index.tsx +8 -2
- package/dist/eject-theme/components/CodeBlock/index.scss +8 -6
- package/dist/eject-theme/components/CodeBlock/index.tsx +4 -0
- package/dist/eject-theme/components/CodeBlockRuntime/index.tsx +50 -11
- package/dist/eject-theme/components/DocContent/doc.scss +1 -1
- package/dist/eject-theme/components/DocContent/docComponents/pre.tsx +2 -1
- package/dist/eject-theme/components/DocContent/index.tsx +21 -4
- package/dist/eject-theme/components/DocFooter/index.tsx +1 -6
- package/dist/eject-theme/components/HoverGroup/index.scss +4 -3
- package/dist/eject-theme/components/HoverGroup/index.tsx +104 -22
- package/dist/eject-theme/components/LastUpdated/index.tsx +8 -1
- package/dist/eject-theme/components/Link/index.tsx +9 -2
- package/dist/eject-theme/components/Nav/NavMenu.scss +1 -1
- package/dist/eject-theme/components/Nav/NavMenu.tsx +50 -28
- package/dist/eject-theme/components/NavScreen/NavScreenLangs.scss +6 -0
- package/dist/eject-theme/components/NavScreen/NavScreenLangs.tsx +23 -9
- package/dist/eject-theme/components/NavScreen/NavScreenMenuItem.tsx +26 -11
- package/dist/eject-theme/components/NavScreen/NavScreenVersions.scss +6 -0
- package/dist/eject-theme/components/NavScreen/NavScreenVersions.tsx +22 -9
- package/dist/eject-theme/components/Overview/index.tsx +66 -6
- package/dist/eject-theme/components/{Overview/OverviewGroup.scss → OverviewGroup/index.scss} +66 -12
- package/dist/eject-theme/components/{Overview/OverviewGroup.tsx → OverviewGroup/index.tsx} +50 -3
- package/dist/eject-theme/components/Search/logic/util.test.ts +1 -1
- package/dist/eject-theme/components/Tabs/index.scss +12 -4
- package/dist/eject-theme/components/Tabs/index.tsx +16 -0
- package/dist/eject-theme/components/Tag/index.tsx +84 -5
- package/dist/index.js +7 -11
- package/dist/node/PluginDriver.js +5 -6
- package/dist/node/auto-nav-sidebar/index.js +3 -3
- package/dist/node/auto-nav-sidebar/locales.js +1 -1
- package/dist/node/auto-nav-sidebar/normalize.js +12 -10
- package/dist/node/auto-nav-sidebar/utils.js +2 -2
- package/dist/node/auto-nav-sidebar/walk.js +13 -9
- package/dist/node/constants.d.ts +1 -0
- package/dist/node/constants.js +4 -3
- package/dist/node/eject.js +7 -10
- package/dist/node/initRsbuild.js +25 -11
- package/dist/node/last-updated/index.js +1 -1
- package/dist/node/logger/hint.js +1 -1
- package/dist/node/mdx/loader.7c249a26.js +12 -0
- package/dist/node/mdx/loader.js +2 -1
- package/dist/node/mdx/options.js +9 -6
- package/dist/node/mdx/processor.js +2 -2
- package/dist/node/mdx/rehypePlugins/codeMeta.js +1 -1
- package/dist/node/mdx/rehypePlugins/headerAnchor.js +4 -4
- package/dist/node/mdx/rehypePlugins/shiki.js +1 -1
- package/dist/node/mdx/rehypePlugins/transformers/index.js +5 -5
- package/dist/node/mdx/remarkPlugins/builtin.js +1 -1
- package/dist/node/mdx/remarkPlugins/containerSyntax.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.js +3 -3
- package/dist/node/mdx/remarkPlugins/toc.js +3 -3
- package/dist/node/medium-zoom/index.js +1 -1
- package/dist/node/route/RoutePage.js +1 -1
- package/dist/node/route/RouteService.js +3 -3
- package/dist/node/route/extractPageData.js +5 -5
- package/dist/node/route/normalizeRoutePath.js +2 -2
- package/dist/node/runtimeModule/i18n.js +2 -2
- package/dist/node/runtimeModule/pageData/createPageData.js +2 -2
- 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/renderPage.js +2 -2
- package/dist/node/ssg/renderPageWorker.165b5d46.js +1 -0
- package/dist/node/ssg/renderPageWorker.js +2 -2
- package/dist/node/ssg/renderPages.js +3 -3
- package/dist/node/ssg/rsbuildPluginSSG.js +2 -2
- package/dist/node/ssg/ssgEnv.js +1 -1
- package/dist/node/ssg-md/llms/emitLlmsTxt.js +9 -3
- package/dist/node/ssg-md/llms/llmsTxt.js +2 -2
- package/dist/node/ssg-md/remarkSplitMdx.js +141 -99
- package/dist/node/ssg-md/renderPage.js +2 -2
- package/dist/node/ssg-md/renderPages.js +2 -2
- package/dist/node/ssg-md/rsbuildPluginSSGMD.js +2 -2
- package/dist/node/utils/checkLanguageParity.js +1 -1
- package/dist/node/utils/createHash.js +1 -1
- package/dist/node/utils/error.js +2 -1
- package/dist/node/utils/flattenMdxContent.js +5 -5
- package/dist/node/utils/fs.js +1 -1
- package/dist/node/utils/getPageKey.js +1 -1
- package/dist/node/utils/normalizePath.js +3 -3
- package/dist/node/utils/reactAlias.js +2 -2
- package/dist/runtime/App.js +4 -2
- package/dist/runtime/initPageData.js +1 -1
- package/dist/runtime.js +1 -2
- package/dist/shiki-transformers.js +2 -2
- package/dist/theme/assets/deprecated.js +18 -0
- package/dist/theme/assets/experimental.js +21 -0
- package/dist/theme/components/Badge/index.css +1 -0
- package/dist/theme/components/Banner/index.js +2 -2
- package/dist/theme/components/Callout/index.js +5 -2
- package/dist/theme/components/CodeBlock/index.css +7 -6
- package/dist/theme/components/CodeBlock/index.js +4 -1
- package/dist/theme/components/CodeBlockRuntime/index.d.ts +1 -1
- package/dist/theme/components/CodeBlockRuntime/index.js +38 -8
- package/dist/theme/components/DocContent/doc.css +1 -1
- package/dist/theme/components/DocContent/docComponents/pre.js +3 -1
- package/dist/theme/components/DocContent/index.d.ts +11 -2
- package/dist/theme/components/DocContent/index.js +6 -5
- package/dist/theme/components/DocFooter/index.js +1 -5
- package/dist/theme/components/HoverGroup/index.css +6 -5
- package/dist/theme/components/HoverGroup/index.js +88 -17
- package/dist/theme/components/LastUpdated/index.d.ts +1 -1
- package/dist/theme/components/LastUpdated/index.js +5 -1
- package/dist/theme/components/Link/index.d.ts +1 -1
- package/dist/theme/components/Link/index.js +8 -2
- package/dist/theme/components/Nav/NavMenu.css +1 -1
- package/dist/theme/components/Nav/NavMenu.d.ts +6 -1
- package/dist/theme/components/Nav/NavMenu.js +47 -45
- package/dist/theme/components/NavScreen/NavScreenLangs.css +6 -0
- package/dist/theme/components/NavScreen/NavScreenLangs.js +13 -3
- package/dist/theme/components/NavScreen/NavScreenMenuItem.d.ts +1 -1
- package/dist/theme/components/NavScreen/NavScreenMenuItem.js +21 -11
- package/dist/theme/components/NavScreen/NavScreenVersions.css +6 -0
- package/dist/theme/components/NavScreen/NavScreenVersions.js +12 -3
- package/dist/theme/components/Overview/index.d.ts +0 -1
- package/dist/theme/components/Overview/index.js +46 -3
- package/dist/theme/components/{Overview/OverviewGroup.css → OverviewGroup/index.css} +60 -8
- package/dist/theme/components/{Overview/OverviewGroup.d.ts → OverviewGroup/index.d.ts} +1 -1
- package/dist/theme/components/OverviewGroup/index.js +88 -0
- package/dist/theme/components/Search/logic/util.test.js +1 -1
- package/dist/theme/components/Tabs/index.css +6 -5
- package/dist/theme/components/Tabs/index.js +9 -0
- package/dist/theme/components/Tag/index.d.ts +3 -0
- package/dist/theme/components/Tag/index.js +63 -8
- package/dist/theme/hooks/useActiveAnchor.js +1 -1
- package/dist/theme/icons.d.ts +26 -24
- package/dist/theme/icons.js +5 -1
- package/dist/theme/index.d.ts +3 -1
- package/dist/theme/index.js +4 -2
- package/dist/theme/layout/DocLayout/index.css +0 -2
- package/dist/theme/layout/DocLayout/index.js +10 -0
- package/dist/theme/layout/HomeLayout/index.js +40 -0
- package/dist/theme/layout/Layout/index.js +11 -8
- package/dist/theme/layout/NotFountLayout/index.js +1 -1
- package/dist/theme/logic/useAppearance.js +1 -1
- package/dist/theme/logic/useMediaQuery.js +1 -1
- package/dist/theme/logic/useStorageValue.js +6 -3
- package/dist/theme/styles/base.css +1 -0
- package/dist/theme/styles/shiki.css +9 -3
- package/dist/theme/styles/vars/base-vars.css +4 -4
- package/dist/theme/styles/vars/code-vars.css +2 -0
- package/nav-json-schema.json +2 -2
- package/package.json +15 -15
- package/dist/1218.3869bad6.js +0 -2
- package/dist/4669.12208c6a.js +0 -2
- package/dist/6289.c67fe0d5.js +0 -5
- package/dist/7805.cadab34e.js +0 -4
- package/dist/8813.9da1f210.js +0 -2
- package/dist/cli/index.cb89dbd1.js +0 -3
- package/dist/node/mdx/loader.e1578c62.js +0 -13
- package/dist/node/ssg/renderPageWorker.474f9f73.js +0 -2
- package/dist/theme/components/Overview/OverviewGroup.js +0 -57
- /package/dist/eject-theme/components/{Overview → OverviewGroup}/icons/plugin.svg +0 -0
- /package/dist/theme/components/{Overview → OverviewGroup}/icons/plugin.js +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { getCustomMDXComponent } from "@theme";
|
|
3
3
|
import { toJsxRuntime } from "hast-util-to-jsx-runtime";
|
|
4
|
-
import { Fragment, useEffect, useRef, useState } from "react";
|
|
4
|
+
import { Fragment, useEffect, useMemo, useRef, useState } from "react";
|
|
5
5
|
import { codeToHast, createCssVariablesTheme } from "shiki";
|
|
6
6
|
const cssVariablesTheme = createCssVariablesTheme({
|
|
7
7
|
name: 'css-variables',
|
|
@@ -14,8 +14,33 @@ const useLatest = (value)=>{
|
|
|
14
14
|
ref.current = value;
|
|
15
15
|
return ref;
|
|
16
16
|
};
|
|
17
|
-
function CodeBlockRuntime({ lang, title, code, shikiOptions, codeButtonGroupProps, children: _, containerElementClassName, onRendered,
|
|
18
|
-
const
|
|
17
|
+
function CodeBlockRuntime({ lang, title, code, shikiOptions, codeButtonGroupProps, children: _, containerElementClassName, onRendered, wrapCode, lineNumbers }) {
|
|
18
|
+
const mdxComponents = useMemo(()=>getCustomMDXComponent(), []);
|
|
19
|
+
const { pre: ShikiPre, code: Code, ...otherMdxComponents } = mdxComponents;
|
|
20
|
+
const fallback = useMemo(()=>/*#__PURE__*/ jsx(ShikiPre, {
|
|
21
|
+
title: title,
|
|
22
|
+
lang: lang,
|
|
23
|
+
wrapCode: wrapCode,
|
|
24
|
+
lineNumbers: lineNumbers,
|
|
25
|
+
containerElementClassName: containerElementClassName,
|
|
26
|
+
codeButtonGroupProps: codeButtonGroupProps,
|
|
27
|
+
className: "shiki css-variables",
|
|
28
|
+
children: /*#__PURE__*/ jsx(Code, {
|
|
29
|
+
style: {
|
|
30
|
+
padding: '1rem 1.25rem'
|
|
31
|
+
},
|
|
32
|
+
children: code
|
|
33
|
+
})
|
|
34
|
+
}), [
|
|
35
|
+
title,
|
|
36
|
+
lang,
|
|
37
|
+
wrapCode,
|
|
38
|
+
lineNumbers,
|
|
39
|
+
containerElementClassName,
|
|
40
|
+
codeButtonGroupProps,
|
|
41
|
+
code
|
|
42
|
+
]);
|
|
43
|
+
const [child, setChild] = useState(fallback);
|
|
19
44
|
const codeRef = useLatest(code);
|
|
20
45
|
useEffect(()=>{
|
|
21
46
|
const highlightCode = async ()=>{
|
|
@@ -25,7 +50,6 @@ function CodeBlockRuntime({ lang, title, code, shikiOptions, codeButtonGroupProp
|
|
|
25
50
|
...shikiOptions
|
|
26
51
|
});
|
|
27
52
|
if (codeRef.current.length !== code.length) return;
|
|
28
|
-
const { pre: ShikiPre, code: Code, ...otherMdxComponents } = getCustomMDXComponent();
|
|
29
53
|
const reactNode = toJsxRuntime(hast, {
|
|
30
54
|
jsx: jsx,
|
|
31
55
|
jsxs: jsxs,
|
|
@@ -37,8 +61,9 @@ function CodeBlockRuntime({ lang, title, code, shikiOptions, codeButtonGroupProp
|
|
|
37
61
|
lang: lang,
|
|
38
62
|
containerElementClassName: containerElementClassName,
|
|
39
63
|
codeButtonGroupProps: codeButtonGroupProps,
|
|
40
|
-
|
|
41
|
-
|
|
64
|
+
wrapCode: wrapCode,
|
|
65
|
+
lineNumbers: lineNumbers,
|
|
66
|
+
...props
|
|
42
67
|
}),
|
|
43
68
|
code: (props)=>/*#__PURE__*/ jsx(Code, {
|
|
44
69
|
...props
|
|
@@ -50,9 +75,14 @@ function CodeBlockRuntime({ lang, title, code, shikiOptions, codeButtonGroupProp
|
|
|
50
75
|
};
|
|
51
76
|
highlightCode();
|
|
52
77
|
}, [
|
|
53
|
-
lang,
|
|
54
78
|
code,
|
|
55
|
-
|
|
79
|
+
codeButtonGroupProps,
|
|
80
|
+
containerElementClassName,
|
|
81
|
+
lang,
|
|
82
|
+
lineNumbers,
|
|
83
|
+
shikiOptions,
|
|
84
|
+
title,
|
|
85
|
+
wrapCode
|
|
56
86
|
]);
|
|
57
87
|
useEffect(()=>{
|
|
58
88
|
if (child) onRendered?.();
|
|
@@ -9,7 +9,9 @@ function ShikiPre({ title, lang, wrapCode, lineNumbers, containerElementClassNam
|
|
|
9
9
|
containerElementClassName: containerElementClassName,
|
|
10
10
|
codeButtonGroupProps: codeButtonGroupProps,
|
|
11
11
|
children: /*#__PURE__*/ jsx("pre", {
|
|
12
|
-
...otherProps
|
|
12
|
+
...otherProps,
|
|
13
|
+
"data-lang": lang,
|
|
14
|
+
"data-title": title
|
|
13
15
|
})
|
|
14
16
|
});
|
|
15
17
|
}
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import './doc.scss';
|
|
2
|
-
export declare function
|
|
3
|
-
export declare function DocContent({ components, isOverviewPage, }: {
|
|
2
|
+
export declare function DocContent({ components, isOverviewPage, afterDocContent, beforeDocContent, }: {
|
|
4
3
|
components: Record<string, React.FC<any>> | undefined;
|
|
5
4
|
isOverviewPage?: boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Optional React node rendered before the main document content.
|
|
7
|
+
* Can be used for banners, notices, or custom elements at the top of the page.
|
|
8
|
+
*/
|
|
9
|
+
beforeDocContent?: React.ReactNode;
|
|
10
|
+
/**
|
|
11
|
+
* Optional React node rendered after the main document content.
|
|
12
|
+
* Can be used for footers, navigation, or other content at the bottom of the page.
|
|
13
|
+
*/
|
|
14
|
+
afterDocContent?: React.ReactNode;
|
|
6
15
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { MDXProvider } from "@mdx-js/react";
|
|
3
3
|
import { Content, usePage, useSite } from "@rspress/core/runtime";
|
|
4
|
-
import { Callout, FallbackHeading, getCustomMDXComponent } from "@theme";
|
|
5
|
-
import { useScrollAfterNav } from "../../logic/useScrollAfterNav.js";
|
|
4
|
+
import { Callout, FallbackHeading, getCustomMDXComponent, useScrollAfterNav } from "@theme";
|
|
6
5
|
import "./doc.css";
|
|
7
6
|
function FallbackTitle() {
|
|
8
7
|
const { site } = useSite();
|
|
@@ -13,7 +12,7 @@ function FallbackTitle() {
|
|
|
13
12
|
title: title
|
|
14
13
|
});
|
|
15
14
|
}
|
|
16
|
-
function DocContent({ components, isOverviewPage = false }) {
|
|
15
|
+
function DocContent({ components, isOverviewPage = false, afterDocContent, beforeDocContent }) {
|
|
17
16
|
useScrollAfterNav();
|
|
18
17
|
const mdxComponents = {
|
|
19
18
|
...getCustomMDXComponent(),
|
|
@@ -23,9 +22,11 @@ function DocContent({ components, isOverviewPage = false }) {
|
|
|
23
22
|
return /*#__PURE__*/ jsxs(MDXProvider, {
|
|
24
23
|
components: mdxComponents,
|
|
25
24
|
children: [
|
|
25
|
+
beforeDocContent,
|
|
26
26
|
!isOverviewPage && /*#__PURE__*/ jsx(FallbackTitle, {}),
|
|
27
|
-
/*#__PURE__*/ jsx(Content, {})
|
|
27
|
+
/*#__PURE__*/ jsx(Content, {}),
|
|
28
|
+
afterDocContent
|
|
28
29
|
]
|
|
29
30
|
});
|
|
30
31
|
}
|
|
31
|
-
export { DocContent
|
|
32
|
+
export { DocContent };
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useSite } from "@rspress/core/runtime";
|
|
3
2
|
import { EditLink, LastUpdated, PrevNextPage } from "@theme";
|
|
4
3
|
import "./index.css";
|
|
5
4
|
function DocFooter() {
|
|
6
|
-
const { site } = useSite();
|
|
7
|
-
const { themeConfig } = site;
|
|
8
|
-
const showLastUpdated = themeConfig.lastUpdated;
|
|
9
5
|
return /*#__PURE__*/ jsxs("footer", {
|
|
10
6
|
className: "rp-doc-footer",
|
|
11
7
|
children: [
|
|
@@ -13,7 +9,7 @@ function DocFooter() {
|
|
|
13
9
|
className: "rp-doc-footer__edit",
|
|
14
10
|
children: [
|
|
15
11
|
/*#__PURE__*/ jsx(EditLink, {}),
|
|
16
|
-
|
|
12
|
+
/*#__PURE__*/ jsx(LastUpdated, {})
|
|
17
13
|
]
|
|
18
14
|
}),
|
|
19
15
|
/*#__PURE__*/ jsx("div", {
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
.rp-hover-group {
|
|
2
2
|
border: var(--rp-code-block-border);
|
|
3
3
|
background: var(--rp-c-bg);
|
|
4
|
+
width: auto;
|
|
5
|
+
min-width: 80px;
|
|
6
|
+
box-shadow: var(--rp-shadow-2);
|
|
4
7
|
z-index: 999;
|
|
5
8
|
border-radius: 8px;
|
|
6
9
|
flex-direction: column;
|
|
7
10
|
align-items: flex-start;
|
|
8
|
-
width: auto;
|
|
9
|
-
min-width: 80px;
|
|
10
11
|
padding: 8px;
|
|
11
12
|
list-style: none;
|
|
12
13
|
transition: opacity .3s ease-in-out;
|
|
13
14
|
display: flex;
|
|
14
15
|
position: absolute;
|
|
15
16
|
top: 80%;
|
|
16
|
-
box-shadow: 0 4px 16px #0000000a;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
.rp-hover-group--center {
|
|
@@ -43,7 +43,6 @@
|
|
|
43
43
|
border-radius: 8px;
|
|
44
44
|
flex: 1;
|
|
45
45
|
align-self: stretch;
|
|
46
|
-
padding-left: 8px;
|
|
47
46
|
padding-right: 8px;
|
|
48
47
|
font-size: 14px;
|
|
49
48
|
font-style: normal;
|
|
@@ -54,8 +53,10 @@
|
|
|
54
53
|
}
|
|
55
54
|
|
|
56
55
|
.rp-hover-group__item__link {
|
|
56
|
+
align-items: center;
|
|
57
|
+
gap: 2px;
|
|
57
58
|
height: 100%;
|
|
58
|
-
display:
|
|
59
|
+
display: flex;
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
.rp-hover-group__item--active {
|
|
@@ -1,7 +1,89 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { matchNavbar, useLocation } from "@rspress/core/runtime";
|
|
3
|
+
import { Link, Tag } from "@theme";
|
|
3
4
|
import clsx from "clsx";
|
|
4
5
|
import "./index.css";
|
|
6
|
+
function HoverGroupItem({ item, activeMatcher, depth = 0 }) {
|
|
7
|
+
const { pathname } = useLocation();
|
|
8
|
+
if ('items' in item && item.items && item.items.length > 0) {
|
|
9
|
+
const hasLink = 'link' in item && item.link;
|
|
10
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
11
|
+
children: [
|
|
12
|
+
hasLink && /*#__PURE__*/ jsx("li", {
|
|
13
|
+
className: "rp-hover-group__item",
|
|
14
|
+
style: {
|
|
15
|
+
paddingLeft: `${8 + 12 * depth}px`
|
|
16
|
+
},
|
|
17
|
+
"data-depth": depth,
|
|
18
|
+
children: /*#__PURE__*/ jsxs(Link, {
|
|
19
|
+
href: item.link,
|
|
20
|
+
"aria-label": item.text,
|
|
21
|
+
className: "rp-hover-group__item__link",
|
|
22
|
+
children: [
|
|
23
|
+
item.text,
|
|
24
|
+
'tag' in item && item.tag && /*#__PURE__*/ jsx(Tag, {
|
|
25
|
+
tag: item.tag
|
|
26
|
+
})
|
|
27
|
+
]
|
|
28
|
+
})
|
|
29
|
+
}, item.text),
|
|
30
|
+
item.items.map((subItem)=>/*#__PURE__*/ jsx(HoverGroupItem, {
|
|
31
|
+
item: subItem,
|
|
32
|
+
activeMatcher: activeMatcher,
|
|
33
|
+
depth: depth + 1
|
|
34
|
+
}, subItem.text))
|
|
35
|
+
]
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
if ('link' in item) {
|
|
39
|
+
const { text, link } = item;
|
|
40
|
+
const isActiveItem = activeMatcher ? activeMatcher(item) : matchNavbar(item, pathname);
|
|
41
|
+
return /*#__PURE__*/ jsx("li", {
|
|
42
|
+
className: clsx('rp-hover-group__item', {
|
|
43
|
+
'rp-hover-group__item--active': isActiveItem
|
|
44
|
+
}),
|
|
45
|
+
style: {
|
|
46
|
+
paddingLeft: `${8 + 12 * depth}px`
|
|
47
|
+
},
|
|
48
|
+
"data-depth": depth,
|
|
49
|
+
children: link ? /*#__PURE__*/ jsxs(Link, {
|
|
50
|
+
href: link,
|
|
51
|
+
"aria-label": text,
|
|
52
|
+
className: "rp-hover-group__item__link",
|
|
53
|
+
children: [
|
|
54
|
+
text,
|
|
55
|
+
'tag' in item && item.tag && /*#__PURE__*/ jsx(Tag, {
|
|
56
|
+
tag: item.tag
|
|
57
|
+
})
|
|
58
|
+
]
|
|
59
|
+
}) : /*#__PURE__*/ jsxs("div", {
|
|
60
|
+
className: "rp-hover-group__item__link",
|
|
61
|
+
children: [
|
|
62
|
+
text,
|
|
63
|
+
'tag' in item && item.tag && /*#__PURE__*/ jsx(Tag, {
|
|
64
|
+
tag: item.tag
|
|
65
|
+
})
|
|
66
|
+
]
|
|
67
|
+
})
|
|
68
|
+
}, text + link);
|
|
69
|
+
}
|
|
70
|
+
return /*#__PURE__*/ jsx("li", {
|
|
71
|
+
className: "rp-hover-group__item",
|
|
72
|
+
style: {
|
|
73
|
+
paddingLeft: `${8 + 12 * depth}px`
|
|
74
|
+
},
|
|
75
|
+
"data-depth": depth,
|
|
76
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
77
|
+
className: "rp-hover-group__item__link",
|
|
78
|
+
children: [
|
|
79
|
+
item.text,
|
|
80
|
+
'tag' in item && item.tag && /*#__PURE__*/ jsx(Tag, {
|
|
81
|
+
tag: item.tag
|
|
82
|
+
})
|
|
83
|
+
]
|
|
84
|
+
})
|
|
85
|
+
}, item.text);
|
|
86
|
+
}
|
|
5
87
|
function HoverGroup({ items, customChildren, isOpen, position = 'center', activeMatcher }) {
|
|
6
88
|
return /*#__PURE__*/ jsx("ul", {
|
|
7
89
|
className: clsx('rp-hover-group', {
|
|
@@ -10,21 +92,10 @@ function HoverGroup({ items, customChildren, isOpen, position = 'center', active
|
|
|
10
92
|
'rp-hover-group--center': 'center' === position,
|
|
11
93
|
'rp-hover-group--right': 'right' === position
|
|
12
94
|
}),
|
|
13
|
-
children: customChildren ?? items?.map((item)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
className: clsx('rp-hover-group__item', {
|
|
18
|
-
'rp-hover-group__item--active': isActiveItem
|
|
19
|
-
}),
|
|
20
|
-
children: /*#__PURE__*/ jsx(Link, {
|
|
21
|
-
href: link,
|
|
22
|
-
"aria-label": text,
|
|
23
|
-
className: "rp-hover-group__item__link",
|
|
24
|
-
children: text
|
|
25
|
-
})
|
|
26
|
-
}, text + link);
|
|
27
|
-
})
|
|
95
|
+
children: customChildren ?? items?.map((item)=>/*#__PURE__*/ jsx(HoverGroupItem, {
|
|
96
|
+
item: item,
|
|
97
|
+
activeMatcher: activeMatcher
|
|
98
|
+
}, item.text))
|
|
28
99
|
});
|
|
29
100
|
}
|
|
30
101
|
export { HoverGroup };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import './index.scss';
|
|
2
|
-
export declare function LastUpdated(): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare function LastUpdated(): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useI18n, usePage } from "@rspress/core/runtime";
|
|
2
|
+
import { useI18n, usePage, useSite } from "@rspress/core/runtime";
|
|
3
3
|
import "./index.css";
|
|
4
4
|
function LastUpdated() {
|
|
5
5
|
const { page: { lastUpdatedTime } } = usePage();
|
|
6
|
+
const { site } = useSite();
|
|
7
|
+
const { themeConfig } = site;
|
|
8
|
+
const showLastUpdated = themeConfig.lastUpdated;
|
|
6
9
|
const t = useI18n();
|
|
10
|
+
if (!showLastUpdated) return null;
|
|
7
11
|
return /*#__PURE__*/ jsx("div", {
|
|
8
12
|
className: "rp-last-updated",
|
|
9
13
|
children: /*#__PURE__*/ jsxs("p", {
|
|
@@ -32,4 +32,4 @@ export interface LinkProps extends ComponentProps<'a'> {
|
|
|
32
32
|
* 3. If inCurrentSite, it will navigate and scroll to anchor, preload the asyncChunk onHover the link
|
|
33
33
|
* 4. Link is styled.
|
|
34
34
|
*/
|
|
35
|
-
export declare
|
|
35
|
+
export declare const Link: React.ForwardRefExoticComponent<Omit<LinkProps, "ref"> & React.RefAttributes<HTMLAnchorElement>>;
|
|
@@ -2,18 +2,20 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { preloadLink } from "@rspress/core/runtime";
|
|
3
3
|
import clsx from "clsx";
|
|
4
4
|
import nprogress from "nprogress";
|
|
5
|
+
import { forwardRef } from "react";
|
|
5
6
|
import "./index.css";
|
|
6
7
|
import { getHref, useLinkNavigate } from "./useLinkNavigate.js";
|
|
7
8
|
nprogress.configure({
|
|
8
9
|
showSpinner: false
|
|
9
10
|
});
|
|
10
|
-
|
|
11
|
+
const Link = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
11
12
|
const { href = '/', children, className = '', onClick, onMouseEnter, startTransition, ...otherProps } = props;
|
|
12
13
|
const { linkType, removeBaseHref, withBaseHref } = getHref(href);
|
|
13
14
|
const navigate = useLinkNavigate({
|
|
14
15
|
startTransition
|
|
15
16
|
});
|
|
16
17
|
if ('external' === linkType) return /*#__PURE__*/ jsx("a", {
|
|
18
|
+
ref: ref,
|
|
17
19
|
href: href,
|
|
18
20
|
target: "_blank",
|
|
19
21
|
rel: "noopener noreferrer",
|
|
@@ -24,6 +26,7 @@ function Link(props) {
|
|
|
24
26
|
children: children
|
|
25
27
|
});
|
|
26
28
|
if ('hashOnly' === linkType) return /*#__PURE__*/ jsx("a", {
|
|
29
|
+
ref: ref,
|
|
27
30
|
href: href,
|
|
28
31
|
className: clsx(className, 'rp-link'),
|
|
29
32
|
onClick: onClick,
|
|
@@ -32,6 +35,7 @@ function Link(props) {
|
|
|
32
35
|
children: children
|
|
33
36
|
});
|
|
34
37
|
if ('relative' === linkType) return /*#__PURE__*/ jsx("a", {
|
|
38
|
+
ref: ref,
|
|
35
39
|
href: href,
|
|
36
40
|
className: clsx(className, 'rp-link'),
|
|
37
41
|
onMouseEnter: (event)=>{
|
|
@@ -48,6 +52,7 @@ function Link(props) {
|
|
|
48
52
|
children: children
|
|
49
53
|
});
|
|
50
54
|
return /*#__PURE__*/ jsx("a", {
|
|
55
|
+
ref: ref,
|
|
51
56
|
href: withBaseHref,
|
|
52
57
|
className: clsx(className, 'rp-link'),
|
|
53
58
|
onMouseEnter: (event)=>{
|
|
@@ -63,5 +68,6 @@ function Link(props) {
|
|
|
63
68
|
...otherProps,
|
|
64
69
|
children: children
|
|
65
70
|
});
|
|
66
|
-
}
|
|
71
|
+
});
|
|
72
|
+
Link.displayName = 'Link';
|
|
67
73
|
export { Link };
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import type { NavItem, NavItemWithChildren, NavItemWithLink, NavItemWithLinkAndChildren } from '@rspress/core';
|
|
2
2
|
import type { HoverGroupProps } from '@theme';
|
|
3
|
+
import { type ReactNode } from 'react';
|
|
3
4
|
import './NavMenu.scss';
|
|
4
5
|
export declare const SvgDown: (props: React.SVGProps<SVGSVGElement>) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare function NavMenuItemInner({ menuItem, children, }: {
|
|
7
|
+
menuItem: Partial<NavItemWithLink>;
|
|
8
|
+
children?: ReactNode;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
5
10
|
export declare function NavMenuItemWithChildren({ menuItem, activeMatcher, }: {
|
|
6
11
|
menuItem: NavItemWithChildren | NavItemWithLinkAndChildren;
|
|
7
12
|
activeMatcher?: HoverGroupProps['activeMatcher'];
|
|
@@ -9,7 +14,7 @@ export declare function NavMenuItemWithChildren({ menuItem, activeMatcher, }: {
|
|
|
9
14
|
export declare function NavMenuItemWithLink({ menuItem, }: {
|
|
10
15
|
menuItem: NavItemWithLink;
|
|
11
16
|
}): import("react/jsx-runtime").JSX.Element;
|
|
12
|
-
export declare function NavMenuItem({ menuItem
|
|
17
|
+
export declare function NavMenuItem({ menuItem }: {
|
|
13
18
|
menuItem: NavItem;
|
|
14
19
|
}): import("react/jsx-runtime").JSX.Element;
|
|
15
20
|
export declare function NavMenuDivider(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { matchNavbar, useLocation } from "@rspress/core/runtime";
|
|
3
3
|
import { IconArrowDown, Link, SvgWrapper, Tag, useHoverGroup } from "@theme";
|
|
4
4
|
import clsx from "clsx";
|
|
@@ -9,47 +9,50 @@ const SvgDown = (props)=>/*#__PURE__*/ jsx(SvgWrapper, {
|
|
|
9
9
|
icon: IconArrowDown,
|
|
10
10
|
...props
|
|
11
11
|
});
|
|
12
|
+
function NavMenuItemInner({ menuItem, children }) {
|
|
13
|
+
return /*#__PURE__*/ jsx(Fragment, {
|
|
14
|
+
children: 'link' in menuItem && 'string' == typeof menuItem.link ? /*#__PURE__*/ jsxs(Link, {
|
|
15
|
+
href: menuItem.link,
|
|
16
|
+
className: "rp-nav-menu__item__container",
|
|
17
|
+
children: [
|
|
18
|
+
menuItem.text,
|
|
19
|
+
menuItem.tag && /*#__PURE__*/ jsx(Tag, {
|
|
20
|
+
tag: menuItem.tag
|
|
21
|
+
}),
|
|
22
|
+
children
|
|
23
|
+
]
|
|
24
|
+
}) : /*#__PURE__*/ jsxs("div", {
|
|
25
|
+
className: "rp-nav-menu__item__container",
|
|
26
|
+
children: [
|
|
27
|
+
menuItem.text,
|
|
28
|
+
menuItem.tag && /*#__PURE__*/ jsx(Tag, {
|
|
29
|
+
tag: menuItem.tag
|
|
30
|
+
}),
|
|
31
|
+
children
|
|
32
|
+
]
|
|
33
|
+
})
|
|
34
|
+
});
|
|
35
|
+
}
|
|
12
36
|
function NavMenuItemWithChildren({ menuItem, activeMatcher }) {
|
|
13
37
|
const { handleMouseEnter, handleMouseLeave, hoverGroup } = useHoverGroup({
|
|
14
38
|
items: menuItem.items,
|
|
15
39
|
activeMatcher
|
|
16
40
|
});
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
className: "rp-nav-menu__item__container",
|
|
20
|
-
children: [
|
|
21
|
-
menuItem.text,
|
|
22
|
-
menuItem.tag && /*#__PURE__*/ jsx(Tag, {
|
|
23
|
-
tag: menuItem.tag
|
|
24
|
-
}),
|
|
25
|
-
/*#__PURE__*/ jsx(SvgDown, {
|
|
26
|
-
className: "rp-nav-menu__item__icon"
|
|
27
|
-
})
|
|
28
|
-
]
|
|
29
|
-
}) : /*#__PURE__*/ jsxs("div", {
|
|
30
|
-
className: "rp-nav-menu__item__container",
|
|
31
|
-
children: [
|
|
32
|
-
menuItem.text,
|
|
33
|
-
menuItem.tag && /*#__PURE__*/ jsx(Tag, {
|
|
34
|
-
tag: menuItem.tag
|
|
35
|
-
}),
|
|
36
|
-
/*#__PURE__*/ jsx(SvgDown, {
|
|
37
|
-
className: "rp-nav-menu__item__icon"
|
|
38
|
-
})
|
|
39
|
-
]
|
|
40
|
-
});
|
|
41
|
-
return menuItem.items.length > 0 ? /*#__PURE__*/ jsxs("li", {
|
|
41
|
+
const hasItems = menuItem.items.length > 0;
|
|
42
|
+
return /*#__PURE__*/ jsxs("li", {
|
|
42
43
|
className: "rp-nav-menu__item",
|
|
43
44
|
onMouseEnter: handleMouseEnter,
|
|
44
45
|
onMouseLeave: handleMouseLeave,
|
|
45
46
|
onClick: handleMouseEnter,
|
|
46
47
|
children: [
|
|
47
|
-
|
|
48
|
+
/*#__PURE__*/ jsx(NavMenuItemInner, {
|
|
49
|
+
menuItem: menuItem,
|
|
50
|
+
children: hasItems && /*#__PURE__*/ jsx(SvgDown, {
|
|
51
|
+
className: "rp-nav-menu__item__icon"
|
|
52
|
+
})
|
|
53
|
+
}),
|
|
48
54
|
hoverGroup
|
|
49
55
|
]
|
|
50
|
-
}) : /*#__PURE__*/ jsx("li", {
|
|
51
|
-
className: "rp-nav-menu__item",
|
|
52
|
-
children: inner
|
|
53
56
|
});
|
|
54
57
|
}
|
|
55
58
|
function NavMenuItemWithLink({ menuItem }) {
|
|
@@ -60,24 +63,23 @@ function NavMenuItemWithLink({ menuItem }) {
|
|
|
60
63
|
]);
|
|
61
64
|
return /*#__PURE__*/ jsx("li", {
|
|
62
65
|
className: clsx('rp-nav-menu__item', isActive ? 'rp-nav-menu__item--active' : '', 'rspress-nav-menu-item', isActive ? 'rspress-nav-menu-item-active' : ''),
|
|
63
|
-
children: /*#__PURE__*/
|
|
64
|
-
|
|
65
|
-
className: "rp-nav-menu__item__container",
|
|
66
|
-
children: [
|
|
67
|
-
menuItem.text,
|
|
68
|
-
menuItem.tag && /*#__PURE__*/ jsx(Tag, {
|
|
69
|
-
tag: menuItem.tag
|
|
70
|
-
})
|
|
71
|
-
]
|
|
66
|
+
children: /*#__PURE__*/ jsx(NavMenuItemInner, {
|
|
67
|
+
menuItem: menuItem
|
|
72
68
|
})
|
|
73
69
|
});
|
|
74
70
|
}
|
|
75
|
-
function NavMenuItem({ menuItem
|
|
76
|
-
if ('items' in
|
|
77
|
-
menuItem:
|
|
71
|
+
function NavMenuItem({ menuItem }) {
|
|
72
|
+
if ('items' in menuItem && Array.isArray(menuItem.items) && menuItem.items.length > 0) return /*#__PURE__*/ jsx(NavMenuItemWithChildren, {
|
|
73
|
+
menuItem: menuItem
|
|
78
74
|
});
|
|
79
|
-
return /*#__PURE__*/ jsx(NavMenuItemWithLink, {
|
|
80
|
-
menuItem:
|
|
75
|
+
if ('link' in menuItem && menuItem.link.length > 0) return /*#__PURE__*/ jsx(NavMenuItemWithLink, {
|
|
76
|
+
menuItem: menuItem
|
|
77
|
+
});
|
|
78
|
+
return /*#__PURE__*/ jsx("li", {
|
|
79
|
+
className: "rp-nav-menu__item",
|
|
80
|
+
children: /*#__PURE__*/ jsx(NavMenuItemInner, {
|
|
81
|
+
menuItem: menuItem
|
|
82
|
+
})
|
|
81
83
|
});
|
|
82
84
|
}
|
|
83
85
|
function NavMenuDivider() {
|
|
@@ -118,4 +120,4 @@ function NavMenu({ menuItems, position }) {
|
|
|
118
120
|
}, index))
|
|
119
121
|
});
|
|
120
122
|
}
|
|
121
|
-
export { NavLangs, NavMenu, NavMenuDivider, NavMenuItem, NavMenuItemWithChildren, NavMenuItemWithLink, NavVersions, SvgDown };
|
|
123
|
+
export { NavLangs, NavMenu, NavMenuDivider, NavMenuItem, NavMenuItemInner, NavMenuItemWithChildren, NavMenuItemWithLink, NavVersions, SvgDown };
|
|
@@ -4,6 +4,7 @@ import { useLangsMenu } from "../Nav/hooks.js";
|
|
|
4
4
|
import "./NavScreenLangs.css";
|
|
5
5
|
import { useI18n } from "@rspress/core/runtime";
|
|
6
6
|
import { Link } from "@theme";
|
|
7
|
+
import clsx from "clsx";
|
|
7
8
|
import { SvgDown } from "./NavScreenMenuItem.js";
|
|
8
9
|
function NavScreenLangs() {
|
|
9
10
|
const { items, activeValue } = useLangsMenu();
|
|
@@ -39,11 +40,20 @@ function NavScreenLangs() {
|
|
|
39
40
|
},
|
|
40
41
|
children: /*#__PURE__*/ jsx("div", {
|
|
41
42
|
className: "rp-nav-screen-langs-group__inner",
|
|
42
|
-
children: items.map((item)
|
|
43
|
+
children: items.map((item)=>{
|
|
44
|
+
const isActive = item.text === activeValue;
|
|
45
|
+
const className = clsx('rp-nav-screen-langs-group__item', isActive && 'rp-nav-screen-langs-group__item--active');
|
|
46
|
+
return isActive ? /*#__PURE__*/ jsx("span", {
|
|
47
|
+
className: className,
|
|
48
|
+
"aria-current": "page",
|
|
49
|
+
"aria-disabled": true,
|
|
50
|
+
children: item.text
|
|
51
|
+
}, item.text) : /*#__PURE__*/ jsx(Link, {
|
|
43
52
|
href: item.link,
|
|
44
|
-
className:
|
|
53
|
+
className: className,
|
|
45
54
|
children: item.text
|
|
46
|
-
}, item.text)
|
|
55
|
+
}, item.text);
|
|
56
|
+
})
|
|
47
57
|
})
|
|
48
58
|
})
|
|
49
59
|
]
|
|
@@ -21,5 +21,5 @@ export declare function NavScreenMenuItemWithChildren({ menuItem, }: NavScreenMe
|
|
|
21
21
|
interface NavScreenMenuItemProps {
|
|
22
22
|
menuItem: NavItem;
|
|
23
23
|
}
|
|
24
|
-
export declare function NavScreenMenuItem({ menuItem
|
|
24
|
+
export declare function NavScreenMenuItem({ menuItem }: NavScreenMenuItemProps): import("react/jsx-runtime").JSX.Element;
|
|
25
25
|
export {};
|