@rspress/core 2.0.0-rc.1 → 2.0.0-rc.3
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/bin/rspress.js +1 -1
- package/dist/0~7675.723d12b2.js +1794 -0
- package/dist/3521.56e42d70.js +56 -0
- package/dist/4669.12208c6a.js +2 -0
- package/dist/5485.077f14ff.js +98 -0
- package/dist/6289.c67fe0d5.js +5 -0
- package/dist/8813.9da1f210.js +2 -0
- package/dist/9643.f109822d.js +5 -0
- package/dist/_private/react/render.js +17 -4
- package/dist/cli/config/index.js +4 -0
- package/dist/cli/config/loadConfigFile.js +30 -0
- package/dist/cli/index.cb89dbd1.js +3 -0
- package/dist/cli/index.js +122 -0
- package/dist/eject-theme/components/Badge/index.scss +1 -0
- package/dist/eject-theme/components/Banner/index.tsx +6 -5
- package/dist/eject-theme/components/Callout/index.scss +0 -2
- package/dist/eject-theme/components/Callout/index.tsx +8 -2
- package/dist/eject-theme/components/CodeBlock/index.scss +12 -18
- package/dist/eject-theme/components/CodeBlock/index.tsx +10 -1
- package/dist/eject-theme/components/CodeBlockRuntime/index.tsx +50 -11
- package/dist/eject-theme/components/CodeButtonGroup/CopyCodeButton.tsx +1 -3
- package/dist/eject-theme/components/CodeButtonGroup/index.scss +5 -1
- package/dist/eject-theme/components/CodeButtonGroup/index.tsx +1 -3
- package/dist/eject-theme/components/DocContent/doc.scss +27 -7
- package/dist/eject-theme/components/DocContent/docComponents/pre.tsx +2 -1
- package/dist/eject-theme/components/DocContent/docComponents/table.tsx +10 -4
- 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/{DocContent/FallbackHeading.tsx → FallbackHeading/index.tsx} +20 -11
- package/dist/eject-theme/components/HoverGroup/index.scss +1 -1
- package/dist/eject-theme/components/LastUpdated/index.tsx +8 -1
- package/dist/eject-theme/components/Link/index.tsx +22 -6
- package/dist/eject-theme/components/Nav/NavMenu.tsx +2 -3
- package/dist/eject-theme/components/NavHamburger/index.tsx +3 -4
- 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 +2 -3
- 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 +7 -8
- package/dist/eject-theme/components/{Overview/OverviewGroup.scss → OverviewGroup/index.scss} +66 -12
- package/dist/eject-theme/components/{Overview/OverviewGroup.tsx → OverviewGroup/index.tsx} +51 -5
- package/dist/eject-theme/components/PackageManagerTabs/index.tsx +12 -0
- package/dist/eject-theme/components/PrevNextPage/index.tsx +6 -3
- package/dist/eject-theme/components/Root/index.tsx +58 -0
- package/dist/eject-theme/components/Search/NoSearchResult.tsx +2 -3
- package/dist/eject-theme/components/Search/SearchButton.tsx +3 -4
- package/dist/eject-theme/components/Search/SearchPanel.tsx +12 -7
- package/dist/eject-theme/components/Search/SuggestItem.tsx +15 -12
- package/dist/eject-theme/components/Search/logic/util.test.ts +1 -1
- package/dist/eject-theme/components/Sidebar/SidebarGroup.tsx +2 -3
- package/dist/eject-theme/components/Sidebar/SidebarItem.tsx +1 -0
- package/dist/eject-theme/components/SidebarMenu/index.tsx +4 -4
- package/dist/eject-theme/components/SocialLinks/index.tsx +2 -3
- package/dist/eject-theme/components/SourceCode/index.tsx +6 -4
- package/dist/eject-theme/components/SwitchAppearance/index.tsx +3 -5
- package/dist/eject-theme/components/Tabs/index.scss +31 -26
- package/dist/eject-theme/components/Tabs/index.tsx +16 -0
- package/dist/eject-theme/components/Tag/index.tsx +84 -5
- package/dist/eject-theme/components/Toc/TocItem.scss +3 -3
- package/dist/eject-theme/components/Toc/TocItem.tsx +1 -0
- package/dist/index.d.ts +6 -6
- package/dist/index.js +16 -3134
- package/dist/node/PluginDriver.d.ts +1 -1
- package/dist/node/PluginDriver.js +142 -0
- package/dist/node/auto-nav-sidebar/index.js +44 -0
- package/dist/node/auto-nav-sidebar/locales.js +26 -0
- package/dist/node/auto-nav-sidebar/normalize.js +230 -0
- package/dist/node/auto-nav-sidebar/utils.js +68 -0
- package/dist/node/auto-nav-sidebar/walk.js +67 -0
- package/dist/node/build.js +31 -0
- package/dist/node/constants.d.ts +2 -0
- package/dist/node/constants.js +34 -0
- package/dist/node/dev.js +32 -0
- package/dist/node/eject.js +111 -0
- package/dist/node/index.d.ts +5 -5
- package/dist/node/initRsbuild.d.ts +2 -2
- package/dist/node/initRsbuild.js +346 -0
- package/dist/node/last-updated/index.js +28 -0
- package/dist/node/logger/hint.d.ts +1 -1
- package/dist/node/logger/hint.js +85 -0
- package/dist/node/mdx/loader.d.ts +1 -1
- package/dist/node/mdx/loader.e1578c62.js +13 -0
- package/dist/{loader.js → node/mdx/loader.js} +4 -3
- package/dist/node/mdx/options.d.ts +2 -2
- package/dist/node/mdx/options.js +103 -0
- package/dist/node/mdx/processor.d.ts +2 -2
- package/dist/node/mdx/processor.js +71 -0
- package/dist/node/mdx/rehypePlugins/codeMeta.js +10 -0
- package/dist/node/mdx/rehypePlugins/headerAnchor.js +53 -0
- package/dist/node/mdx/rehypePlugins/shiki.js +34 -0
- package/dist/node/mdx/rehypePlugins/transformers/add-lang.js +15 -0
- package/dist/node/mdx/rehypePlugins/transformers/add-line-numbers.js +22 -0
- package/dist/node/mdx/rehypePlugins/transformers/add-title.js +24 -0
- package/dist/node/mdx/rehypePlugins/transformers/add-wrap-code.js +22 -0
- package/dist/node/mdx/rehypePlugins/transformers/index.d.ts +5 -5
- package/dist/node/mdx/rehypePlugins/transformers/index.js +5 -0
- package/dist/node/mdx/rehypePlugins/transformers/meta-highlight.js +41 -0
- package/dist/node/mdx/remarkPlugins/builtin.js +11 -0
- package/dist/node/mdx/remarkPlugins/containerSyntax.js +190 -0
- package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +66 -0
- package/dist/node/mdx/remarkPlugins/image.js +67 -0
- package/dist/node/mdx/remarkPlugins/link.d.ts +1 -1
- package/dist/node/mdx/remarkPlugins/link.js +99 -0
- package/dist/node/mdx/remarkPlugins/toc.js +50 -0
- package/dist/node/mdx/types.d.ts +3 -3
- package/dist/node/medium-zoom/index.d.ts +1 -1
- package/dist/node/medium-zoom/index.js +14 -0
- package/dist/node/route/RoutePage.d.ts +1 -1
- package/dist/node/route/RoutePage.js +61 -0
- package/dist/node/route/RouteService.d.ts +1 -1
- package/dist/node/route/RouteService.js +177 -0
- package/dist/node/route/extractPageData.d.ts +1 -1
- package/dist/node/route/extractPageData.js +112 -0
- package/dist/node/route/normalizeRoutePath.js +54 -0
- package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.d.ts +21 -0
- package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.js +150 -0
- package/dist/node/runtimeModule/globalStyles.d.ts +1 -1
- package/dist/node/runtimeModule/globalStyles.js +12 -0
- package/dist/node/runtimeModule/globalUIComponents.d.ts +1 -1
- package/dist/node/runtimeModule/globalUIComponents.js +25 -0
- package/dist/node/runtimeModule/i18n.d.ts +2 -2
- package/dist/node/runtimeModule/i18n.js +83 -0
- package/dist/node/runtimeModule/pageData/createPageData.d.ts +1 -1
- package/dist/node/runtimeModule/pageData/createPageData.js +64 -0
- package/dist/node/runtimeModule/pageData/rsbuildPlugin.d.ts +1 -1
- package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +51 -0
- package/dist/node/runtimeModule/routeList.d.ts +1 -1
- package/dist/node/runtimeModule/routeList.js +7 -0
- package/dist/node/runtimeModule/searchHooks.d.ts +1 -1
- package/dist/node/runtimeModule/searchHooks.js +11 -0
- package/dist/node/runtimeModule/siteData/createSiteData.js +34 -0
- package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +94 -0
- package/dist/node/runtimeModule/siteData/rsbuildPlugin.d.ts +1 -1
- package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +24 -0
- package/dist/node/runtimeModule/socialLinks.d.ts +1 -1
- package/dist/node/runtimeModule/socialLinks.js +8 -0
- package/dist/node/runtimeModule/types.d.ts +2 -2
- package/dist/node/serve.js +23 -0
- package/dist/node/ssg/renderHtmlTemplate.js +33 -0
- package/dist/node/ssg/renderPage.js +34 -0
- package/dist/node/ssg/renderPageWorker.474f9f73.js +2 -0
- package/dist/node/ssg/renderPageWorker.js +15 -0
- package/dist/node/ssg/renderPages.d.ts +1 -1
- package/dist/node/ssg/renderPages.js +105 -0
- package/dist/node/ssg/renderPages.js.LICENSE.txt +4 -0
- package/dist/node/ssg/rsbuildPluginCSR.d.ts +1 -1
- package/dist/node/ssg/rsbuildPluginCSR.js +27 -0
- package/dist/node/ssg/rsbuildPluginSSG.d.ts +1 -1
- package/dist/node/ssg/rsbuildPluginSSG.js +72 -0
- package/dist/node/ssg/ssgEnv.js +33 -0
- package/dist/node/ssg/ssgEnv.js.LICENSE.txt +5 -0
- package/dist/node/ssg-md/llms/emitLlmsTxt.d.ts +1 -1
- package/dist/node/ssg-md/llms/emitLlmsTxt.js +84 -0
- package/dist/node/ssg-md/llms/llmsTxt.d.ts +1 -1
- package/dist/node/ssg-md/llms/llmsTxt.js +66 -0
- package/dist/node/ssg-md/react/index.d.ts +1 -1
- package/dist/node/ssg-md/remarkSplitMdx.js +244 -0
- package/dist/node/ssg-md/renderPage.js +31 -0
- package/dist/node/ssg-md/renderPages.d.ts +1 -1
- package/dist/node/ssg-md/renderPages.js +27 -0
- package/dist/node/ssg-md/rsbuildPluginSSGMD.d.ts +1 -1
- package/dist/node/ssg-md/rsbuildPluginSSGMD.js +47 -0
- package/dist/node/utils/applyReplaceRules.js +6 -0
- package/dist/node/utils/checkLanguageParity.js +77 -0
- package/dist/node/utils/createHash.js +5 -0
- package/dist/node/utils/error.d.ts +9 -0
- package/dist/node/utils/error.js +10 -0
- package/dist/node/utils/escapeHeadingIds.js +5 -0
- package/dist/node/utils/flattenMdxContent.js +74 -0
- package/dist/node/utils/fs.js +14 -0
- package/dist/node/utils/getImportAstNode.js +63 -0
- package/dist/node/utils/getPageKey.js +6 -0
- package/dist/node/utils/getSocialIcons.js +32 -0
- package/dist/node/utils/index.d.ts +10 -9
- package/dist/node/utils/normalizePath.js +10 -0
- package/dist/node/utils/reactAlias.d.ts +2 -0
- package/dist/node/utils/reactAlias.js +83 -0
- package/dist/rslib-runtime.99091bf6.js +18 -0
- package/dist/runtime/App.js +2 -2
- package/dist/runtime/ClientApp.d.ts +1 -1
- package/dist/runtime/ClientApp.js +0 -4
- package/dist/runtime/initPageData.js +1 -1
- package/dist/runtime/ssrMdServerEntry.js +1 -1
- package/dist/runtime/ssrServerEntry.js +2 -1
- package/dist/runtime.72d450ac.js +1 -0
- package/dist/runtime.js +3 -2
- package/dist/shiki-transformers.d.ts +1 -1
- package/dist/shiki-transformers.js +6 -120
- 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.d.ts +1 -1
- package/dist/theme/components/Banner/index.js +4 -5
- package/dist/theme/components/Callout/index.css +0 -2
- package/dist/theme/components/Callout/index.js +5 -2
- package/dist/theme/components/CodeBlock/index.css +11 -21
- package/dist/theme/components/CodeBlock/index.js +5 -1
- package/dist/theme/components/CodeBlockRuntime/index.d.ts +1 -1
- package/dist/theme/components/CodeBlockRuntime/index.js +38 -8
- package/dist/theme/components/CodeButtonGroup/CopyCodeButton.js +3 -5
- package/dist/theme/components/CodeButtonGroup/index.css +5 -1
- package/dist/theme/components/CodeButtonGroup/index.js +3 -5
- package/dist/theme/components/DocContent/doc.css +28 -7
- package/dist/theme/components/DocContent/docComponents/index.d.ts +3 -3
- package/dist/theme/components/DocContent/docComponents/pre.js +3 -1
- package/dist/theme/components/DocContent/docComponents/table.d.ts +2 -2
- package/dist/theme/components/DocContent/docComponents/table.js +8 -3
- package/dist/theme/components/DocContent/index.d.ts +11 -2
- package/dist/theme/components/DocContent/index.js +6 -6
- package/dist/theme/components/DocFooter/index.js +1 -5
- package/dist/theme/components/{DocContent/FallbackHeading.js → FallbackHeading/index.js} +19 -11
- package/dist/theme/components/HoverGroup/index.css +3 -3
- package/dist/theme/components/HoverGroup/useHoverGroup.d.ts +1 -1
- 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 +17 -7
- package/dist/theme/components/Nav/NavMenu.js +2 -3
- package/dist/theme/components/NavHamburger/index.js +3 -4
- package/dist/theme/components/NavScreen/NavScreenLangs.css +6 -0
- package/dist/theme/components/NavScreen/NavScreenLangs.js +13 -3
- package/dist/theme/components/NavScreen/NavScreenMenuItem.js +2 -3
- 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 +2 -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/PackageManagerTabs/index.d.ts +1 -1
- package/dist/theme/components/PackageManagerTabs/index.js +4 -0
- package/dist/theme/components/PrevNextPage/index.js +3 -4
- package/dist/theme/components/Root/index.d.ts +54 -0
- package/dist/theme/components/Root/index.js +7 -0
- package/dist/theme/components/Search/NoSearchResult.js +2 -3
- package/dist/theme/components/Search/SearchButton.js +3 -4
- package/dist/theme/components/Search/SearchPanel.js +12 -15
- package/dist/theme/components/Search/SuggestItem.d.ts +1 -1
- package/dist/theme/components/Search/SuggestItem.js +7 -11
- package/dist/theme/components/Search/logic/Provider.d.ts +1 -1
- package/dist/theme/components/Search/logic/providers/LocalProvider.d.ts +2 -2
- package/dist/theme/components/Search/logic/search.d.ts +1 -1
- package/dist/theme/components/Search/logic/util.test.js +1 -1
- package/dist/theme/components/Sidebar/SidebarGroup.js +2 -3
- package/dist/theme/components/Sidebar/SidebarItem.js +1 -0
- package/dist/theme/components/SidebarMenu/index.js +3 -5
- package/dist/theme/components/SocialLinks/index.js +2 -3
- package/dist/theme/components/SourceCode/index.js +2 -4
- package/dist/theme/components/SwitchAppearance/index.js +3 -5
- package/dist/theme/components/Tabs/index.css +19 -27
- 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/components/Toc/TocItem.css +2 -3
- package/dist/theme/components/Toc/TocItem.js +1 -0
- package/dist/theme/hooks/useActiveAnchor.js +1 -1
- package/dist/theme/icons.d.ts +27 -0
- package/dist/theme/icons.js +51 -0
- package/dist/theme/index.d.ts +64 -59
- package/dist/theme/index.js +7 -2
- package/dist/theme/layout/DocLayout/index.css +2 -4
- package/dist/theme/layout/Layout/index.js +1 -2
- package/dist/theme/layout/NotFountLayout/index.js +1 -1
- package/dist/theme/logic/useAppearance.js +1 -1
- package/dist/theme/logic/useFullTextSearch.d.ts +1 -1
- package/dist/theme/logic/useMediaQuery.js +1 -1
- package/dist/theme/styles/base.css +1 -0
- package/dist/theme/styles/scrollbar.css +1 -0
- package/dist/theme/styles/shiki.css +9 -3
- package/dist/theme/styles/vars/base-vars.css +7 -5
- package/dist/theme/styles/vars/code-vars.css +2 -0
- package/dist/theme/styles/vars/home-vars.css +2 -1
- package/package.json +22 -23
- package/dist/3~128.js +0 -74
- package/dist/3~517.js +0 -1786
- package/dist/3~894.js +0 -26
- package/dist/cli.js +0 -259
- package/dist/index.js.LICENSE.txt +0 -10
- package/dist/node/auto-nav-sidebar/fixtures/docs/guide/c.d.ts +0 -2
- package/dist/node/auto-nav-sidebar/fixtures/docs-locales/en/guide/c.d.ts +0 -2
- package/dist/node/auto-nav-sidebar/fixtures/docs-locales/zh/guide/c.d.ts +0 -2
- package/dist/node/auto-nav-sidebar/locales.test.d.ts +0 -1
- package/dist/node/auto-nav-sidebar/walk.test.d.ts +0 -1
- package/dist/node/mdx/rehypePlugins/headerAnchor.test.d.ts +0 -1
- package/dist/node/mdx/remarkPlugins/containerSyntax.test.d.ts +0 -1
- package/dist/node/mdx/remarkPlugins/fileCodeBlock.test.d.ts +0 -1
- package/dist/node/mdx/remarkPlugins/image.test.d.ts +0 -1
- package/dist/node/mdx/remarkPlugins/link.test.d.ts +0 -1
- package/dist/node/route/RouteService.test.d.ts +0 -1
- package/dist/node/route/extractPageData.test.d.ts +0 -1
- package/dist/node/route/fixtures/basic/guide/c.d.ts +0 -2
- package/dist/node/route/normalizeRoutePath.test.d.ts +0 -1
- package/dist/node/runtimeModule/i18n.test.d.ts +0 -1
- package/dist/node/ssg-md/remarkSplitMdx.test.d.ts +0 -4
- package/dist/node/utils/checkLanguageParity.test.d.ts +0 -1
- package/dist/node/utils/detectCustomIcon.d.ts +0 -1
- package/dist/node/utils/detectReactVersion.d.ts +0 -3
- package/dist/processor.js +0 -4539
- package/dist/renderPageWorker.js +0 -196
- package/dist/theme/components/Overview/OverviewGroup.js +0 -58
- package/dist/theme/components/Search/logic/util.test.d.ts +0 -1
- /package/dist/cli/{config.d.ts → config/index.d.ts} +0 -0
- /package/dist/eject-theme/components/{Overview → OverviewGroup}/icons/plugin.svg +0 -0
- /package/dist/{shiki-transformers.js.LICENSE.txt → node/mdx/rehypePlugins/transformers/meta-highlight.js.LICENSE.txt} +0 -0
- /package/dist/theme/components/{DocContent/FallbackHeading.d.ts → FallbackHeading/index.d.ts} +0 -0
- /package/dist/theme/components/{Overview → OverviewGroup}/icons/plugin.js +0 -0
|
@@ -23,7 +23,7 @@ export type BannerProps = {
|
|
|
23
23
|
/**
|
|
24
24
|
* @example
|
|
25
25
|
* // theme/index.tsx
|
|
26
|
-
* import { Layout as BasicLayout, Banner } from '@rspress/core/theme';
|
|
26
|
+
* import { Layout as BasicLayout, Banner } from '@rspress/core/theme-original';
|
|
27
27
|
* import { useLang } from '@rspress/core/runtime';
|
|
28
28
|
* const Layout = () => {
|
|
29
29
|
const lang = useLang();
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Link, SvgWrapper, mergeRefs } from "@theme";
|
|
3
|
-
import _theme_assets_close from "@theme-assets/close";
|
|
2
|
+
import { IconClose, Link, SvgWrapper, mergeRefs } from "@theme";
|
|
4
3
|
import clsx from "clsx";
|
|
5
4
|
import { forwardRef, useEffect, useState } from "react";
|
|
6
5
|
import "./index.css";
|
|
@@ -8,11 +7,11 @@ const Banner = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
|
|
|
8
7
|
const { href, message, display = true, className, storageKey = 'rp-banner-closed', storage = 'localStorage', customChildren } = props;
|
|
9
8
|
const [height, setHeight] = useState(36);
|
|
10
9
|
const ref = mergeRefs(forwardedRef, (element)=>{
|
|
11
|
-
element?.offsetHeight
|
|
10
|
+
if (element?.offsetHeight) setHeight(element?.offsetHeight);
|
|
12
11
|
});
|
|
13
12
|
const [disable, setDisable] = useState(false);
|
|
14
13
|
useEffect(()=>{
|
|
15
|
-
if (
|
|
14
|
+
if ("u" < typeof window || !storage || !storageKey) return;
|
|
16
15
|
setDisable(Boolean(window[storage].getItem(storageKey)));
|
|
17
16
|
}, []);
|
|
18
17
|
if (!display || disable) return null;
|
|
@@ -29,7 +28,7 @@ const Banner = /*#__PURE__*/ forwardRef((props, forwardedRef)=>{
|
|
|
29
28
|
children: message
|
|
30
29
|
}),
|
|
31
30
|
/*#__PURE__*/ jsx(SvgWrapper, {
|
|
32
|
-
icon:
|
|
31
|
+
icon: IconClose,
|
|
33
32
|
onClick: ()=>{
|
|
34
33
|
setDisable(true);
|
|
35
34
|
if (storage) window[storage].setItem(storageKey, 'true');
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import "./index.css";
|
|
3
|
+
function capitalize(type) {
|
|
4
|
+
return type.charAt(0).toUpperCase() + type.slice(1);
|
|
5
|
+
}
|
|
3
6
|
function Callout({ type, title, children }) {
|
|
4
7
|
const isDetails = 'details' === type;
|
|
5
8
|
if (isDetails) return /*#__PURE__*/ jsxs("details", {
|
|
@@ -7,7 +10,7 @@ function Callout({ type, title, children }) {
|
|
|
7
10
|
children: [
|
|
8
11
|
/*#__PURE__*/ jsx("summary", {
|
|
9
12
|
className: "rp-callout__title",
|
|
10
|
-
children: title
|
|
13
|
+
children: title ?? capitalize(type)
|
|
11
14
|
}),
|
|
12
15
|
/*#__PURE__*/ jsx("div", {
|
|
13
16
|
className: "rp-callout__content",
|
|
@@ -20,7 +23,7 @@ function Callout({ type, title, children }) {
|
|
|
20
23
|
children: [
|
|
21
24
|
/*#__PURE__*/ jsx("div", {
|
|
22
25
|
className: "rp-callout__title",
|
|
23
|
-
children: title
|
|
26
|
+
children: title ?? capitalize(type)
|
|
24
27
|
}),
|
|
25
28
|
/*#__PURE__*/ jsx("div", {
|
|
26
29
|
className: "rp-callout__content",
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
.rp-codeblock {
|
|
2
2
|
border: var(--rp-code-block-border);
|
|
3
|
+
box-shadow: var(--rp-code-block-shadow);
|
|
3
4
|
border-radius: var(--rp-radius);
|
|
4
|
-
margin:
|
|
5
|
+
margin: 1rem 0;
|
|
5
6
|
transition: none;
|
|
6
7
|
position: relative;
|
|
7
8
|
overflow-x: auto;
|
|
@@ -10,7 +11,7 @@
|
|
|
10
11
|
@media (width <= 640px) {
|
|
11
12
|
.rp-codeblock {
|
|
12
13
|
contain: content;
|
|
13
|
-
margin:
|
|
14
|
+
margin: 1.5rem 0;
|
|
14
15
|
}
|
|
15
16
|
}
|
|
16
17
|
|
|
@@ -19,7 +20,7 @@
|
|
|
19
20
|
font-size: var(--rp-code-font-size);
|
|
20
21
|
background-color: var(--rp-code-title-bg);
|
|
21
22
|
border-bottom: var(--rp-code-block-border);
|
|
22
|
-
padding:
|
|
23
|
+
padding: .75rem 1rem;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
.rp-codeblock__content {
|
|
@@ -28,6 +29,10 @@
|
|
|
28
29
|
position: relative;
|
|
29
30
|
}
|
|
30
31
|
|
|
32
|
+
.rp-codeblock__content__scroll-container {
|
|
33
|
+
overflow-x: auto;
|
|
34
|
+
}
|
|
35
|
+
|
|
31
36
|
.rp-codeblock__content :where(pre) {
|
|
32
37
|
text-align: left;
|
|
33
38
|
white-space: pre;
|
|
@@ -41,21 +46,6 @@
|
|
|
41
46
|
outline: none;
|
|
42
47
|
margin: 0;
|
|
43
48
|
position: relative;
|
|
44
|
-
overflow-x: auto;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.rp-codeblock__content :where(pre)::-webkit-scrollbar {
|
|
48
|
-
width: 5px;
|
|
49
|
-
height: 5px;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.rp-codeblock__content :where(pre)::-webkit-scrollbar-corner {
|
|
53
|
-
display: none;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.rp-codeblock__content :where(pre)::-webkit-scrollbar-thumb {
|
|
57
|
-
background-color: var(--rp-code-block-scroll-bar-bg);
|
|
58
|
-
border-radius: 10px;
|
|
59
49
|
}
|
|
60
50
|
|
|
61
51
|
.rp-codeblock__content :where(code) {
|
|
@@ -63,7 +53,7 @@
|
|
|
63
53
|
font-family: var(--rp-font-family-mono);
|
|
64
54
|
width: fit-content;
|
|
65
55
|
min-width: 100%;
|
|
66
|
-
padding:
|
|
56
|
+
padding: 1rem 0;
|
|
67
57
|
line-height: 1.7;
|
|
68
58
|
display: inline-block;
|
|
69
59
|
}
|
|
@@ -83,8 +73,8 @@
|
|
|
83
73
|
counter-increment: step;
|
|
84
74
|
text-align: right;
|
|
85
75
|
color: #738a9466;
|
|
86
|
-
width:
|
|
87
|
-
margin-right:
|
|
76
|
+
width: 1rem;
|
|
77
|
+
margin-right: 1rem;
|
|
88
78
|
display: inline-block;
|
|
89
79
|
}
|
|
90
80
|
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { CodeButtonGroup, useCodeButtonGroup } from "@theme";
|
|
3
3
|
import clsx from "clsx";
|
|
4
4
|
import "./index.css";
|
|
5
5
|
function CodeBlock({ containerElementClassName, title, lang = 'txt', wrapCode: wrapCodeProp = false, lineNumbers: lineNumbersProp = false, codeButtonGroupProps, children }) {
|
|
6
|
+
if (process.env.__SSR_MD__) return /*#__PURE__*/ jsx(Fragment, {
|
|
7
|
+
children: children
|
|
8
|
+
});
|
|
6
9
|
const { codeWrap, toggleCodeWrap, copyElementRef } = useCodeButtonGroup(wrapCodeProp);
|
|
7
10
|
return /*#__PURE__*/ jsxs("div", {
|
|
8
11
|
className: clsx('rp-codeblock', `language-${lang}`, containerElementClassName),
|
|
@@ -15,6 +18,7 @@ function CodeBlock({ containerElementClassName, title, lang = 'txt', wrapCode: w
|
|
|
15
18
|
className: clsx('rp-codeblock__content', codeWrap && 'rp-codeblock__content--code-wrap', lineNumbersProp && 'rp-codeblock__content--line-numbers'),
|
|
16
19
|
children: [
|
|
17
20
|
/*#__PURE__*/ jsx("div", {
|
|
21
|
+
className: "rp-codeblock__content__scroll-container rp-scrollbar",
|
|
18
22
|
ref: copyElementRef,
|
|
19
23
|
children: children
|
|
20
24
|
}),
|
|
@@ -11,4 +11,4 @@ export interface CodeBlockRuntimeProps extends CodeBlockProps {
|
|
|
11
11
|
*/
|
|
12
12
|
onRendered?: () => void;
|
|
13
13
|
}
|
|
14
|
-
export declare function CodeBlockRuntime({ lang, title, code, shikiOptions, codeButtonGroupProps, children: _, containerElementClassName, onRendered,
|
|
14
|
+
export declare function CodeBlockRuntime({ lang, title, code, shikiOptions, codeButtonGroupProps, children: _, containerElementClassName, onRendered, wrapCode, lineNumbers, }: CodeBlockRuntimeProps): ReactNode;
|
|
@@ -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?.();
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { SvgWrapper } from "@theme";
|
|
3
|
-
import copy from "@theme-assets/copy";
|
|
4
|
-
import success from "@theme-assets/success";
|
|
2
|
+
import { IconCopy, IconSuccess, SvgWrapper } from "@theme";
|
|
5
3
|
import copy_to_clipboard from "copy-to-clipboard";
|
|
6
4
|
import { useRef } from "react";
|
|
7
5
|
import "./CopyCodeButton.css";
|
|
@@ -39,11 +37,11 @@ function CopyCodeButton({ codeBlockRef }) {
|
|
|
39
37
|
title: t('codeButtonGroupCopyButtonText'),
|
|
40
38
|
children: [
|
|
41
39
|
/*#__PURE__*/ jsx(SvgWrapper, {
|
|
42
|
-
icon:
|
|
40
|
+
icon: IconCopy,
|
|
43
41
|
className: "rp-code-button-group__icon rp-code-copy-button__icon rp-code-copy-button__icon--copy"
|
|
44
42
|
}),
|
|
45
43
|
/*#__PURE__*/ jsx(SvgWrapper, {
|
|
46
|
-
icon:
|
|
44
|
+
icon: IconSuccess,
|
|
47
45
|
className: "rp-code-button-group__icon rp-code-copy-button__icon rp-code-copy-button__icon--success"
|
|
48
46
|
})
|
|
49
47
|
]
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--rp-code-button-group-z-index: 10;
|
|
3
|
+
}
|
|
4
|
+
|
|
1
5
|
.rp-codeblock__content:hover .rp-code-button-group__button {
|
|
2
6
|
opacity: 1;
|
|
3
7
|
}
|
|
4
8
|
|
|
5
9
|
.rp-code-button-group {
|
|
6
|
-
z-index:
|
|
10
|
+
z-index: var(--rp-code-button-group-z-index);
|
|
7
11
|
gap: 10px;
|
|
8
12
|
display: flex;
|
|
9
13
|
position: absolute;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useSite } from "@rspress/core/runtime";
|
|
3
|
-
import { SvgWrapper } from "@theme";
|
|
4
|
-
import wrap from "@theme-assets/wrap";
|
|
5
|
-
import wrapped from "@theme-assets/wrapped";
|
|
3
|
+
import { IconWrap, IconWrapped, SvgWrapper } from "@theme";
|
|
6
4
|
import clsx from "clsx";
|
|
7
5
|
import { useRef, useState } from "react";
|
|
8
6
|
import "./index.css";
|
|
@@ -32,11 +30,11 @@ function CodeButtonGroup({ codeWrap, toggleCodeWrap, copyElementRef, showCodeWra
|
|
|
32
30
|
title: "Toggle code wrap",
|
|
33
31
|
children: [
|
|
34
32
|
/*#__PURE__*/ jsx(SvgWrapper, {
|
|
35
|
-
icon:
|
|
33
|
+
icon: IconWrapped,
|
|
36
34
|
className: "rp-code-button-group__icon rp-code-button-group__icon--wrapped"
|
|
37
35
|
}),
|
|
38
36
|
/*#__PURE__*/ jsx(SvgWrapper, {
|
|
39
|
-
icon:
|
|
37
|
+
icon: IconWrap,
|
|
40
38
|
className: "rp-code-button-group__icon rp-code-button-group__icon--wrap"
|
|
41
39
|
})
|
|
42
40
|
]
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
.rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(a.rp-link):not(:where(.rp-header-anchor)):hover {
|
|
28
|
-
border-bottom: 1px solid var(--rp-c-brand);
|
|
29
28
|
opacity: .85;
|
|
29
|
+
border-bottom: 1px solid;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
.rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(a.rp-link):not(:where(.rp-header-anchor))[target="_blank"]:after {
|
|
@@ -149,35 +149,55 @@
|
|
|
149
149
|
margin-top: .5rem;
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
+
.rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(.rp-table-scroll-container) {
|
|
153
|
+
overflow-x: auto;
|
|
154
|
+
}
|
|
155
|
+
|
|
152
156
|
.rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(table) {
|
|
157
|
+
table-layout: auto;
|
|
158
|
+
border-collapse: separate;
|
|
159
|
+
border-spacing: 0;
|
|
160
|
+
border: var(--rp-code-block-border);
|
|
153
161
|
border-radius: var(--rp-radius);
|
|
154
162
|
width: 100%;
|
|
155
|
-
box-shadow: inset 0 0 0 .5px var(--rp-c-divider-light);
|
|
156
|
-
outline: 1px solid var(--rp-c-divider-light);
|
|
157
163
|
overflow: hidden;
|
|
158
164
|
}
|
|
159
165
|
|
|
166
|
+
.rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(table)::-webkit-scrollbar {
|
|
167
|
+
width: 5px;
|
|
168
|
+
height: 5px;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(table)::-webkit-scrollbar-corner {
|
|
172
|
+
display: none;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(table)::-webkit-scrollbar-thumb {
|
|
176
|
+
background-color: #0000000d;
|
|
177
|
+
border-radius: 10px;
|
|
178
|
+
}
|
|
179
|
+
|
|
160
180
|
.rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(thead) {
|
|
161
181
|
color: var(--rp-c-text-0);
|
|
162
|
-
background: var(--rp-
|
|
182
|
+
background: var(--rp-code-title-bg);
|
|
163
183
|
}
|
|
164
184
|
|
|
165
185
|
.rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(th) {
|
|
166
186
|
text-align: left;
|
|
167
187
|
border-bottom: 1px solid var(--rp-c-divider-light);
|
|
168
|
-
padding:
|
|
188
|
+
padding: .75rem 1.25rem;
|
|
169
189
|
font-size: .875rem;
|
|
170
190
|
font-weight: 600;
|
|
171
191
|
position: relative;
|
|
172
192
|
}
|
|
173
193
|
|
|
174
194
|
.rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(tbody) {
|
|
175
|
-
background:
|
|
195
|
+
background: var(--rp-c-bg);
|
|
176
196
|
}
|
|
177
197
|
|
|
178
198
|
.rp-doc :not(:where(.rp-not-doc, .rp-not-doc *)):where(td) {
|
|
179
199
|
border-bottom: 1px solid var(--rp-c-divider-light);
|
|
180
|
-
padding:
|
|
200
|
+
padding: .75rem 1.25rem;
|
|
181
201
|
font-size: .875rem;
|
|
182
202
|
}
|
|
183
203
|
|
|
@@ -198,6 +218,7 @@
|
|
|
198
218
|
font-family: var(--rp-font-family-mono);
|
|
199
219
|
border-radius: var(--rp-radius-small);
|
|
200
220
|
background-color: var(--rp-c-text-code-bg);
|
|
221
|
+
border: 1px solid var(--rp-c-text-code-border);
|
|
201
222
|
overflow-wrap: break-word;
|
|
202
223
|
padding: 3px 6px;
|
|
203
224
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Code } from './code';
|
|
2
|
-
import { ShikiPre } from './pre';
|
|
1
|
+
import { Code } from './code.js';
|
|
2
|
+
import { ShikiPre } from './pre.js';
|
|
3
3
|
export declare function getCustomMDXComponent(): {
|
|
4
4
|
h1: (props: React.ComponentProps<"h1">) => import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
h2: (props: React.ComponentProps<"h2">) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -10,7 +10,7 @@ export declare function getCustomMDXComponent(): {
|
|
|
10
10
|
ul: (props: import("react").ComponentProps<"ul">) => import("react/jsx-runtime").JSX.Element;
|
|
11
11
|
ol: (props: import("react").ComponentProps<"ol">) => import("react/jsx-runtime").JSX.Element;
|
|
12
12
|
li: (props: import("react").ComponentProps<"li">) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
-
table: (
|
|
13
|
+
table: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").TableHTMLAttributes<HTMLTableElement>, HTMLTableElement>, "ref"> & import("react").RefAttributes<HTMLTableElement>>;
|
|
14
14
|
td: (props: import("react").ComponentProps<"td">) => import("react/jsx-runtime").JSX.Element;
|
|
15
15
|
th: (props: import("react").ComponentProps<"th">) => import("react/jsx-runtime").JSX.Element;
|
|
16
16
|
tr: (props: import("react").ComponentProps<"tr">) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -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,5 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
export declare const Table: (
|
|
1
|
+
import { type ComponentProps } from 'react';
|
|
2
|
+
export declare const Table: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").TableHTMLAttributes<HTMLTableElement>, HTMLTableElement>, "ref"> & import("react").RefAttributes<HTMLTableElement>>;
|
|
3
3
|
export declare const Tr: (props: ComponentProps<"tr">) => import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
export declare const Td: (props: ComponentProps<"td">) => import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
export declare const Th: (props: ComponentProps<"th">) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
const Table = /*#__PURE__*/ forwardRef((props, ref)=>/*#__PURE__*/ jsx("div", {
|
|
4
|
+
className: "rp-table-scroll-container rp-scrollbar",
|
|
5
|
+
children: /*#__PURE__*/ jsx("table", {
|
|
6
|
+
ref: ref,
|
|
7
|
+
...props
|
|
8
|
+
})
|
|
9
|
+
}));
|
|
5
10
|
const Tr = (props)=>/*#__PURE__*/ jsx("tr", {
|
|
6
11
|
...props
|
|
7
12
|
});
|
|
@@ -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,10 +1,8 @@
|
|
|
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, getCustomMDXComponent } from "@theme";
|
|
4
|
+
import { Callout, FallbackHeading, getCustomMDXComponent, useScrollAfterNav } from "@theme";
|
|
5
5
|
import "./doc.css";
|
|
6
|
-
import { useScrollAfterNav } from "../../logic/useScrollAfterNav.js";
|
|
7
|
-
import { FallbackHeading } from "./FallbackHeading.js";
|
|
8
6
|
function FallbackTitle() {
|
|
9
7
|
const { site } = useSite();
|
|
10
8
|
const { page } = usePage();
|
|
@@ -14,7 +12,7 @@ function FallbackTitle() {
|
|
|
14
12
|
title: title
|
|
15
13
|
});
|
|
16
14
|
}
|
|
17
|
-
function DocContent({ components, isOverviewPage = false }) {
|
|
15
|
+
function DocContent({ components, isOverviewPage = false, afterDocContent, beforeDocContent }) {
|
|
18
16
|
useScrollAfterNav();
|
|
19
17
|
const mdxComponents = {
|
|
20
18
|
...getCustomMDXComponent(),
|
|
@@ -24,9 +22,11 @@ function DocContent({ components, isOverviewPage = false }) {
|
|
|
24
22
|
return /*#__PURE__*/ jsxs(MDXProvider, {
|
|
25
23
|
components: mdxComponents,
|
|
26
24
|
children: [
|
|
25
|
+
beforeDocContent,
|
|
27
26
|
!isOverviewPage && /*#__PURE__*/ jsx(FallbackTitle, {}),
|
|
28
|
-
/*#__PURE__*/ jsx(Content, {})
|
|
27
|
+
/*#__PURE__*/ jsx(Content, {}),
|
|
28
|
+
afterDocContent
|
|
29
29
|
]
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
|
-
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,27 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { renderInlineMarkdown } from "@theme";
|
|
2
|
+
import { getCustomMDXComponent, renderInlineMarkdown } from "@theme";
|
|
3
3
|
import { slug } from "github-slugger";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
import { useMemo } from "react";
|
|
5
|
+
const getHeadingMap = ()=>{
|
|
6
|
+
const { h1, h2, h3, h4, h5, h6 } = getCustomMDXComponent();
|
|
7
|
+
return {
|
|
8
|
+
1: h1,
|
|
9
|
+
2: h2,
|
|
10
|
+
3: h3,
|
|
11
|
+
4: h4,
|
|
12
|
+
5: h5,
|
|
13
|
+
6: h6
|
|
14
|
+
};
|
|
13
15
|
};
|
|
14
16
|
function FallbackHeading({ level, title }) {
|
|
15
17
|
const titleSlug = title && slug(title.trim());
|
|
16
|
-
const Element =
|
|
18
|
+
const Element = useMemo(()=>{
|
|
19
|
+
const headingMap = getHeadingMap();
|
|
20
|
+
return headingMap[level] || headingMap[1];
|
|
21
|
+
}, [
|
|
22
|
+
level
|
|
23
|
+
]);
|
|
24
|
+
const A = useMemo(()=>getCustomMDXComponent().a, []);
|
|
17
25
|
return titleSlug && /*#__PURE__*/ jsxs(Element, {
|
|
18
26
|
id: titleSlug,
|
|
19
27
|
children: [
|
|
@@ -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 {
|
|
@@ -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>>;
|