@rspress/core 2.0.5 → 2.0.7
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~1402.js +1 -0
- package/dist/{0~7675.423f6a06.js → 0~execa.js} +6 -5
- package/dist/1361.js +5 -0
- package/dist/1965.js +7 -0
- package/dist/4454.js +8 -0
- package/dist/{7744.421b464f.js → 4524.js} +20 -5
- package/dist/7397.js +18 -0
- package/dist/{5485.0bb24594.js → 8311.js} +5 -2
- package/dist/8474.js +4 -0
- package/dist/8885.js +4 -0
- package/dist/cli/index.js +2 -3
- package/dist/config/loadConfigFile.js +1 -2
- package/dist/eject-theme/components/Banner/index.tsx +1 -1
- package/dist/eject-theme/components/Button/index.tsx +1 -1
- package/dist/eject-theme/components/CodeBlock/index.scss +54 -1
- package/dist/eject-theme/components/CodeBlock/index.tsx +77 -7
- package/dist/eject-theme/components/CodeBlockRuntime/index.tsx +12 -2
- package/dist/eject-theme/components/CodeButtonGroup/CopyCodeButton.tsx +1 -1
- package/dist/eject-theme/components/CodeButtonGroup/index.tsx +15 -15
- package/dist/eject-theme/components/DocContent/docComponents/a.tsx +1 -1
- package/dist/eject-theme/components/DocContent/docComponents/pre.tsx +5 -1
- package/dist/eject-theme/components/DocContent/docComponents/title.tsx +6 -1
- package/dist/eject-theme/components/DocContent/index.tsx +1 -1
- package/dist/eject-theme/components/DocFooter/index.tsx +1 -1
- package/dist/eject-theme/components/EditLink/index.tsx +1 -1
- package/dist/eject-theme/components/FallbackHeading/index.tsx +4 -1
- package/dist/eject-theme/components/HomeFeature/index.tsx +5 -1
- package/dist/eject-theme/components/HomeFooter/index.tsx +1 -1
- package/dist/eject-theme/components/HomeHero/index.tsx +2 -2
- package/dist/eject-theme/components/HoverGroup/index.tsx +5 -2
- package/dist/eject-theme/components/Link/useLinkNavigate.ts +1 -1
- package/dist/eject-theme/components/Llms/LlmsCopyButton.tsx +3 -2
- package/dist/eject-theme/components/Llms/LlmsCopyRow.tsx +3 -2
- package/dist/eject-theme/components/Llms/LlmsOpenRow.tsx +1 -1
- package/dist/eject-theme/components/Llms/LlmsViewOptions.tsx +3 -2
- package/dist/eject-theme/components/Llms/copy.ts +12 -0
- package/dist/eject-theme/components/Nav/NavMenu.tsx +9 -2
- package/dist/eject-theme/components/Nav/index.tsx +1 -1
- package/dist/eject-theme/components/NavHamburger/index.tsx +6 -1
- package/dist/eject-theme/components/NavScreen/NavScreenAppearance.tsx +1 -1
- package/dist/eject-theme/components/NavScreen/NavScreenLangs.tsx +1 -1
- package/dist/eject-theme/components/NavScreen/NavScreenMenuItem.tsx +5 -1
- package/dist/eject-theme/components/NavScreen/NavScreenMenuOthers.tsx +1 -1
- package/dist/eject-theme/components/NavScreen/NavScreenVersions.tsx +1 -1
- package/dist/eject-theme/components/NavScreen/index.tsx +1 -1
- package/dist/eject-theme/components/NavTitle/index.tsx +1 -1
- package/dist/eject-theme/components/Outline/ScrollToTop.tsx +5 -1
- package/dist/eject-theme/components/Outline/index.tsx +1 -1
- package/dist/eject-theme/components/Overview/index.tsx +1 -1
- package/dist/eject-theme/components/OverviewGroup/index.tsx +2 -2
- package/dist/eject-theme/components/PackageManagerTabs/index.tsx +1 -1
- package/dist/eject-theme/components/PrevNextPage/index.tsx +1 -1
- package/dist/eject-theme/components/Root/index.tsx +1 -1
- package/dist/eject-theme/components/Search/NoSearchResult.tsx +1 -1
- package/dist/eject-theme/components/Search/SearchButton.tsx +1 -1
- package/dist/eject-theme/components/Search/SearchPanel.tsx +3 -1
- package/dist/eject-theme/components/Search/SuggestItem.tsx +1 -1
- package/dist/eject-theme/components/Search/index.tsx +1 -1
- package/dist/eject-theme/components/Sidebar/SidebarGroup.tsx +5 -1
- package/dist/eject-theme/components/Sidebar/SidebarItem.scss +0 -4
- package/dist/eject-theme/components/Sidebar/SidebarItem.tsx +1 -1
- package/dist/eject-theme/components/Sidebar/SidebarSectionHeader.tsx +1 -1
- package/dist/eject-theme/components/SidebarMenu/index.tsx +1 -1
- package/dist/eject-theme/components/SocialLinks/index.tsx +1 -1
- package/dist/eject-theme/components/SourceCode/index.tsx +1 -1
- package/dist/eject-theme/components/SvgWrapper/index.tsx +1 -1
- package/dist/eject-theme/components/SwitchAppearance/index.tsx +1 -1
- package/dist/eject-theme/components/Tabs/index.scss +13 -15
- package/dist/eject-theme/components/Tabs/index.tsx +1 -1
- package/dist/eject-theme/components/Tag/index.tsx +1 -1
- package/dist/eject-theme/components/Toc/TocItem.tsx +5 -1
- package/dist/eject-theme/components/Toc/index.tsx +1 -1
- package/dist/index.js +1 -3
- package/dist/node/PluginDriver.js +3 -8
- package/dist/node/auto-nav-sidebar/index.js +1 -2
- package/dist/node/auto-nav-sidebar/locales.js +1 -1
- package/dist/node/auto-nav-sidebar/normalize.js +3 -2
- package/dist/node/auto-nav-sidebar/utils.js +1 -2
- package/dist/node/auto-nav-sidebar/walk.js +1 -2
- package/dist/node/constants.js +1 -2
- package/dist/node/eject.js +1 -1
- package/dist/node/initRsbuild.js +2 -4
- package/dist/node/last-updated/index.js +1 -1
- package/dist/node/logger/hint.js +4 -1
- package/dist/node/mdx/options.js +1 -3
- package/dist/node/mdx/processor.js +1 -2
- package/dist/node/mdx/rehypePlugins/codeMeta.js +1 -1
- package/dist/node/mdx/rehypePlugins/headerAnchor.js +1 -2
- package/dist/node/mdx/rehypePlugins/shiki.d.ts +1 -1
- package/dist/node/mdx/rehypePlugins/shiki.js +2 -1
- package/dist/node/mdx/rehypePlugins/transformers/add-fold.d.ts +6 -0
- package/dist/node/mdx/rehypePlugins/transformers/add-fold.js +38 -0
- package/dist/node/mdx/rehypePlugins/transformers/index.d.ts +1 -0
- package/dist/node/mdx/rehypePlugins/transformers/index.js +1 -0
- package/dist/node/mdx/rehypePlugins/transformers/meta-highlight.js +1 -1
- package/dist/node/mdx/remarkPlugins/builtin.js +1 -1
- package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +1 -2
- package/dist/node/mdx/remarkPlugins/image.js +1 -1
- package/dist/node/mdx/remarkPlugins/link.js +1 -2
- package/dist/node/mdx/remarkPlugins/toc.js +1 -1
- package/dist/node/medium-zoom/index.js +1 -1
- package/dist/node/route/RoutePage.js +1 -1
- package/dist/node/route/RouteService.js +1 -3
- package/dist/node/route/extractPageData.js +1 -3
- package/dist/node/route/normalizeRoutePath.js +1 -2
- package/dist/node/runtimeModule/i18n.js +2 -3
- package/dist/node/runtimeModule/pageData/createPageData.js +1 -2
- package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -2
- 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 +1 -2
- package/dist/node/ssg/renderPageWorker.js +2 -2
- package/dist/node/ssg/renderPages.js +3 -4
- package/dist/node/ssg/rsbuildPluginSSG.js +1 -2
- package/dist/node/ssg/ssgEnv.d.ts +1 -1
- package/dist/node/ssg/ssgEnv.js +2 -2
- package/dist/node/ssg-md/llms/emitLlmsTxt.js +5 -7
- package/dist/node/ssg-md/llms/llmsTxt.js +1 -2
- package/dist/node/ssg-md/remarkSplitMdx.js +1 -2
- package/dist/node/ssg-md/renderPage.js +1 -2
- package/dist/node/ssg-md/renderPages.js +2 -2
- package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -2
- package/dist/node/utils/checkLanguageParity.js +1 -1
- package/dist/node/utils/createHash.js +1 -1
- package/dist/node/utils/error.js +1 -1
- package/dist/node/utils/flattenMdxContent.js +1 -3
- package/dist/node/utils/fs.js +1 -1
- package/dist/node/utils/getPageKey.js +1 -1
- package/dist/node/utils/normalizePath.js +1 -2
- package/dist/node/utils/reactAlias.js +15 -10
- package/dist/runtime/index.js +20 -21
- package/dist/runtime/ssrMdServerEntry.js +2 -2
- package/dist/runtime/ssrServerEntry.js +2 -2
- package/dist/runtime/utils.d.ts +1 -1
- package/dist/runtime/utils.js +1 -1
- package/dist/shiki-transformers.js +1 -0
- package/dist/theme/assets/arrow-down.js +1 -1
- package/dist/theme/assets/arrow-right.js +1 -1
- package/dist/theme/assets/close.js +1 -1
- package/dist/theme/assets/copy.js +1 -1
- package/dist/theme/assets/deprecated.js +1 -1
- package/dist/theme/assets/down.js +1 -1
- package/dist/theme/assets/edit.js +1 -1
- package/dist/theme/assets/empty.js +1 -1
- package/dist/theme/assets/experimental.js +1 -1
- package/dist/theme/assets/external-link.js +1 -1
- package/dist/theme/assets/file.js +1 -1
- package/dist/theme/assets/github.js +1 -1
- package/dist/theme/assets/gitlab.js +1 -1
- package/dist/theme/assets/header.js +1 -1
- package/dist/theme/assets/jump.js +1 -1
- package/dist/theme/assets/link.js +1 -1
- package/dist/theme/assets/loading.js +1 -1
- package/dist/theme/assets/menu.js +1 -1
- package/dist/theme/assets/moon.js +1 -1
- package/dist/theme/assets/scroll-to-top.js +1 -1
- package/dist/theme/assets/search.js +1 -1
- package/dist/theme/assets/small-menu.js +1 -1
- package/dist/theme/assets/success.js +1 -1
- package/dist/theme/assets/sun.js +1 -1
- package/dist/theme/assets/title.js +1 -1
- package/dist/theme/assets/wrap.js +1 -1
- package/dist/theme/assets/wrapped.js +1 -1
- package/dist/theme/components/Banner/index.js +1 -1
- package/dist/theme/components/Button/index.js +1 -1
- package/dist/theme/components/Callout/index.js +2 -1
- package/dist/theme/components/CodeBlock/index.css +49 -1
- package/dist/theme/components/CodeBlock/index.d.ts +11 -3
- package/dist/theme/components/CodeBlock/index.js +51 -6
- package/dist/theme/components/CodeBlockRuntime/index.d.ts +2 -2
- package/dist/theme/components/CodeBlockRuntime/index.js +10 -2
- package/dist/theme/components/CodeButtonGroup/CopyCodeButton.js +1 -1
- package/dist/theme/components/CodeButtonGroup/index.d.ts +6 -6
- package/dist/theme/components/CodeButtonGroup/index.js +10 -10
- package/dist/theme/components/DocContent/docComponents/a.js +1 -1
- package/dist/theme/components/DocContent/docComponents/pre.d.ts +2 -2
- package/dist/theme/components/DocContent/docComponents/pre.js +4 -2
- package/dist/theme/components/DocContent/docComponents/title.js +1 -1
- package/dist/theme/components/DocContent/index.js +1 -1
- package/dist/theme/components/DocFooter/index.js +1 -1
- package/dist/theme/components/EditLink/index.js +1 -1
- package/dist/theme/components/FallbackHeading/index.js +1 -1
- package/dist/theme/components/HomeBackground/index.css +1 -0
- package/dist/theme/components/HomeFeature/index.css +3 -3
- package/dist/theme/components/HomeFeature/index.js +1 -1
- package/dist/theme/components/HomeFooter/index.js +1 -1
- package/dist/theme/components/HomeHero/index.d.ts +1 -1
- package/dist/theme/components/HomeHero/index.js +1 -1
- package/dist/theme/components/HoverGroup/index.d.ts +1 -1
- package/dist/theme/components/HoverGroup/index.js +4 -1
- package/dist/theme/components/Link/useLinkNavigate.d.ts +1 -1
- package/dist/theme/components/Llms/LlmsCopyButton.js +4 -3
- package/dist/theme/components/Llms/LlmsCopyRow.js +3 -2
- package/dist/theme/components/Llms/LlmsOpenRow.js +1 -1
- package/dist/theme/components/Llms/LlmsViewOptions.js +4 -3
- package/dist/theme/components/Llms/copy.d.ts +1 -0
- package/dist/theme/components/Llms/copy.js +9 -0
- package/dist/theme/components/Llms/index.css +1 -0
- package/dist/theme/components/Llms/index.js +4 -5
- package/dist/theme/components/Nav/NavMenu.d.ts +1 -1
- package/dist/theme/components/Nav/NavMenu.js +2 -1
- package/dist/theme/components/Nav/index.css +1 -1
- package/dist/theme/components/Nav/index.js +1 -1
- package/dist/theme/components/NavHamburger/index.js +1 -1
- package/dist/theme/components/NavScreen/NavScreenAppearance.js +1 -1
- package/dist/theme/components/NavScreen/NavScreenLangs.js +1 -1
- package/dist/theme/components/NavScreen/NavScreenMenuItem.d.ts +2 -1
- package/dist/theme/components/NavScreen/NavScreenMenuItem.js +4 -2
- package/dist/theme/components/NavScreen/NavScreenMenuOthers.js +1 -1
- package/dist/theme/components/NavScreen/NavScreenVersions.js +1 -1
- package/dist/theme/components/NavScreen/index.css +1 -1
- package/dist/theme/components/NavScreen/index.js +1 -1
- package/dist/theme/components/NavTitle/index.js +1 -1
- package/dist/theme/components/Outline/ScrollToTop.js +1 -1
- package/dist/theme/components/Outline/index.js +1 -1
- package/dist/theme/components/Overview/index.d.ts +1 -1
- package/dist/theme/components/Overview/index.js +1 -1
- package/dist/theme/components/OverviewGroup/icons/plugin.js +1 -1
- package/dist/theme/components/OverviewGroup/index.css +1 -0
- package/dist/theme/components/OverviewGroup/index.js +1 -1
- package/dist/theme/components/PackageManagerTabs/index.js +1 -1
- package/dist/theme/components/PrevNextPage/index.js +1 -1
- package/dist/theme/components/Root/index.d.ts +1 -1
- package/dist/theme/components/Search/NoSearchResult.js +1 -1
- package/dist/theme/components/Search/SearchButton.js +1 -1
- package/dist/theme/components/Search/SearchPanel.js +3 -2
- package/dist/theme/components/Search/SuggestItem.js +1 -1
- package/dist/theme/components/Search/index.js +1 -1
- package/dist/theme/components/Search/logic/providers/LocalProvider.js +1 -1
- package/dist/theme/components/Sidebar/SidebarGroup.js +1 -1
- package/dist/theme/components/Sidebar/SidebarItem.css +0 -4
- package/dist/theme/components/Sidebar/SidebarItem.js +1 -1
- package/dist/theme/components/Sidebar/SidebarSectionHeader.js +1 -1
- package/dist/theme/components/SidebarMenu/index.js +1 -1
- package/dist/theme/components/SocialLinks/index.js +1 -1
- package/dist/theme/components/SourceCode/index.js +1 -1
- package/dist/theme/components/SvgWrapper/index.js +1 -1
- package/dist/theme/components/SwitchAppearance/index.js +1 -1
- package/dist/theme/components/Tabs/index.css +14 -8
- package/dist/theme/components/Tabs/index.js +1 -1
- package/dist/theme/components/Tag/index.js +1 -1
- package/dist/theme/components/Toc/TocItem.css +1 -1
- package/dist/theme/components/Toc/TocItem.js +1 -1
- package/dist/theme/components/Toc/index.js +1 -1
- package/dist/theme/index.js +66 -67
- package/dist/theme/layout/DocLayout/index.css +11 -11
- package/dist/theme/layout/DocLayout/index.js +1 -1
- package/dist/theme/layout/HomeLayout/index.js +1 -1
- package/dist/theme/layout/Layout/index.d.ts +2 -2
- package/dist/theme/layout/Layout/index.js +16 -6
- package/dist/theme/layout/NotFountLayout/index.js +1 -1
- package/dist/theme/styles/base.css +7 -4
- package/dist/theme/styles/preflight.css +2 -0
- package/dist/theme/styles/vars/home-vars.css +28 -4
- package/nav-json-schema.json +3 -0
- package/package.json +14 -14
- package/dist/6289.29817fb4.js +0 -4
- package/dist/9348.1beb3e25.js +0 -11
- package/dist/cli/index.44f3184c.js +0 -2
- package/dist/node/mdx/loader.15134034.js +0 -9
- /package/dist/{node/ssg/renderPageWorker.165b5d46.js → 9224.js} +0 -0
- /package/dist/{rslib-runtime.99091bf6.js → rslib-runtime.js} +0 -0
package/dist/runtime/index.js
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import { isDataUrl, isExternalUrl, matchNavbar, matchSidebar, normalizeHref } from "@rspress/shared";
|
|
2
|
-
import { Head } from "@unhead/react";
|
|
3
|
-
import { Content } from "./Content.js";
|
|
4
|
-
import { useActiveMatcher } from "./hooks/useActiveMatcher.js";
|
|
5
|
-
import { ThemeContext, useDark } from "./hooks/useDark.js";
|
|
6
|
-
import { useFrontmatter } from "./hooks/useFrontmatter.js";
|
|
7
|
-
import { useI18n } from "./hooks/useI18n.js";
|
|
8
|
-
import { useLang } from "./hooks/useLang.js";
|
|
9
|
-
import { useLocaleSiteData } from "./hooks/useLocaleSiteData.js";
|
|
10
|
-
import { useNav } from "./hooks/useNav.js";
|
|
11
|
-
import { PageContext, usePage } from "./hooks/usePage.js";
|
|
12
|
-
import { usePageData } from "./hooks/usePageData.js";
|
|
13
|
-
import { usePages } from "./hooks/usePages.js";
|
|
14
|
-
import { getSidebarDataGroup, useSidebar, useSidebarDynamic } from "./hooks/useSidebar.js";
|
|
15
|
-
import { useSite } from "./hooks/useSite.js";
|
|
16
|
-
import { useVersion } from "./hooks/useVersion.js";
|
|
17
|
-
import { useWindowSize } from "./hooks/useWindowSize.js";
|
|
18
|
-
import { NoSSR } from "./NoSSR.js";
|
|
19
|
-
import { isActive, pathnameToRouteService, preloadLink } from "./route.js";
|
|
20
|
-
import { addLeadingSlash, addTrailingSlash, cleanUrlByConfig, isEqualPath, isProduction, normalizeHrefInRuntime, normalizeImagePath, removeBase, removeTrailingSlash, routePathToMdPath, withBase } from "./utils.js";
|
|
21
1
|
export * from "react-router-dom";
|
|
22
|
-
export {
|
|
2
|
+
export { isDataUrl, isExternalUrl, matchNavbar, matchSidebar, normalizeHref } from "@rspress/shared";
|
|
3
|
+
export { Head } from "@unhead/react";
|
|
4
|
+
export { Content } from "./Content.js";
|
|
5
|
+
export { useActiveMatcher } from "./hooks/useActiveMatcher.js";
|
|
6
|
+
export { ThemeContext, useDark } from "./hooks/useDark.js";
|
|
7
|
+
export { useFrontmatter } from "./hooks/useFrontmatter.js";
|
|
8
|
+
export { useI18n } from "./hooks/useI18n.js";
|
|
9
|
+
export { useLang } from "./hooks/useLang.js";
|
|
10
|
+
export { useLocaleSiteData } from "./hooks/useLocaleSiteData.js";
|
|
11
|
+
export { useNav } from "./hooks/useNav.js";
|
|
12
|
+
export { PageContext, usePage } from "./hooks/usePage.js";
|
|
13
|
+
export { usePageData } from "./hooks/usePageData.js";
|
|
14
|
+
export { usePages } from "./hooks/usePages.js";
|
|
15
|
+
export { getSidebarDataGroup, useSidebar, useSidebarDynamic } from "./hooks/useSidebar.js";
|
|
16
|
+
export { useSite } from "./hooks/useSite.js";
|
|
17
|
+
export { useVersion } from "./hooks/useVersion.js";
|
|
18
|
+
export { useWindowSize } from "./hooks/useWindowSize.js";
|
|
19
|
+
export { NoSSR } from "./NoSSR.js";
|
|
20
|
+
export { isActive, pathnameToRouteService, preloadLink } from "./route.js";
|
|
21
|
+
export { addLeadingSlash, addTrailingSlash, cleanUrlByConfig, isEqualPath, isProduction, normalizeHrefInRuntime, normalizeImagePath, removeBase, removeTrailingSlash, routePathToMdPath, withBase } from "./utils.js";
|
|
@@ -5,7 +5,6 @@ import { renderToMarkdownString } from "react-render-to-markdown";
|
|
|
5
5
|
import { StaticRouter } from "react-router-dom";
|
|
6
6
|
import { App } from "./App.js";
|
|
7
7
|
import { initPageData } from "./initPageData.js";
|
|
8
|
-
import { routes } from "virtual-routes";
|
|
9
8
|
const DEFAULT_THEME = 'light';
|
|
10
9
|
async function preloadRoute(pathname) {
|
|
11
10
|
const route = pathnameToRouteService(pathname);
|
|
@@ -36,4 +35,5 @@ async function render(routePath, head) {
|
|
|
36
35
|
appMd
|
|
37
36
|
};
|
|
38
37
|
}
|
|
39
|
-
export {
|
|
38
|
+
export { routes } from "virtual-routes";
|
|
39
|
+
export { render };
|
|
@@ -7,7 +7,6 @@ import { renderToPipeableStream } from "react-dom/server";
|
|
|
7
7
|
import { StaticRouter } from "react-router-dom";
|
|
8
8
|
import { App } from "./App.js";
|
|
9
9
|
import { initPageData } from "./initPageData.js";
|
|
10
|
-
import { routes } from "virtual-routes";
|
|
11
10
|
const DEFAULT_THEME = 'light';
|
|
12
11
|
async function preloadRoute(pathname) {
|
|
13
12
|
const route = pathnameToRouteService(pathname);
|
|
@@ -53,4 +52,5 @@ async function render(routePath, head) {
|
|
|
53
52
|
appHtml
|
|
54
53
|
};
|
|
55
54
|
}
|
|
56
|
-
export {
|
|
55
|
+
export { routes } from "virtual-routes";
|
|
56
|
+
export { render };
|
package/dist/runtime/utils.d.ts
CHANGED
|
@@ -9,4 +9,4 @@ declare function normalizeHrefInRuntime(link: string): string;
|
|
|
9
9
|
declare function cleanUrlByConfig(link: string): string;
|
|
10
10
|
declare function normalizeImagePath(imagePath: string): string;
|
|
11
11
|
declare function routePathToMdPath(routePath: string): string;
|
|
12
|
-
export { addLeadingSlash, addTrailingSlash,
|
|
12
|
+
export { addLeadingSlash, addTrailingSlash, cleanUrlByConfig, isEqualPath, isProduction, normalizeHrefInRuntime, normalizeImagePath, removeBase, removeTrailingSlash, routePathToMdPath, withBase, };
|
package/dist/runtime/utils.js
CHANGED
|
@@ -31,4 +31,4 @@ function routePathToMdPath(routePath) {
|
|
|
31
31
|
function isAbsoluteUrl(path) {
|
|
32
32
|
return isExternalUrl(path) || isDataUrl(path) || path.startsWith('//');
|
|
33
33
|
}
|
|
34
|
-
export { addLeadingSlash, addTrailingSlash, cleanUrlByConfig, isEqualPath, isProduction, normalizeHrefInRuntime, normalizeImagePath, utils_removeBase as removeBase,
|
|
34
|
+
export { addLeadingSlash, addTrailingSlash, cleanUrlByConfig, isEqualPath, isProduction, normalizeHrefInRuntime, normalizeImagePath, removeTrailingSlash, routePathToMdPath, utils_removeBase as removeBase, utils_withBase as withBase };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import "./node/mdx/rehypePlugins/transformers/index.js";
|
|
2
|
+
export { SHIKI_TRANSFORMER_ADD_FOLD, transformerAddFold } from "./node/mdx/rehypePlugins/transformers/add-fold.js";
|
|
2
3
|
export { SHIKI_TRANSFORMER_ADD_LANG, transformerAddLang } from "./node/mdx/rehypePlugins/transformers/add-lang.js";
|
|
3
4
|
export { SHIKI_TRANSFORMER_ADD_LINE_NUMBERS, transformerAddLineNumbers } from "./node/mdx/rehypePlugins/transformers/add-line-numbers.js";
|
|
4
5
|
export { SHIKI_TRANSFORMER_ADD_TITLE, transformerAddTitle } from "./node/mdx/rehypePlugins/transformers/add-title.js";
|
package/dist/theme/assets/sun.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { IconClose, Link, SvgWrapper, mergeRefs } from "@theme";
|
|
2
|
+
import { IconClose, Link, SvgWrapper, mergeRefs } from "@rspress/core/theme";
|
|
3
3
|
import clsx from "clsx";
|
|
4
4
|
import { forwardRef, useEffect, useState } from "react";
|
|
5
5
|
import "./index.css";
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
display: inline-block;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
.rp-codeblock__content--code
|
|
61
|
+
.rp-codeblock__content--wrap-code code {
|
|
62
62
|
white-space: pre-wrap !important;
|
|
63
63
|
word-break: break-all !important;
|
|
64
64
|
}
|
|
@@ -82,3 +82,51 @@
|
|
|
82
82
|
width: 3ch;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
.rp-codeblock__content--fold {
|
|
86
|
+
position: relative;
|
|
87
|
+
overflow: hidden;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.rp-codeblock__content--fold:after {
|
|
91
|
+
content: "";
|
|
92
|
+
background: linear-gradient(to bottom, transparent, var(--rp-code-block-bg));
|
|
93
|
+
pointer-events: none;
|
|
94
|
+
z-index: 2;
|
|
95
|
+
height: 48px;
|
|
96
|
+
position: absolute;
|
|
97
|
+
bottom: 0;
|
|
98
|
+
left: 0;
|
|
99
|
+
right: 0;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.rp-codeblock__fold-btn {
|
|
103
|
+
background-color: var(--rp-code-block-bg);
|
|
104
|
+
width: 100%;
|
|
105
|
+
color: var(--rp-c-text-3);
|
|
106
|
+
cursor: pointer;
|
|
107
|
+
-webkit-user-select: none;
|
|
108
|
+
user-select: none;
|
|
109
|
+
border-radius: 0 0 var(--rp-radius) var(--rp-radius);
|
|
110
|
+
border: none;
|
|
111
|
+
justify-content: center;
|
|
112
|
+
align-items: center;
|
|
113
|
+
padding: 4px 0;
|
|
114
|
+
transition: color .2s, background-color .2s;
|
|
115
|
+
display: flex;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.rp-codeblock__fold-btn:hover {
|
|
119
|
+
color: var(--rp-c-text-1);
|
|
120
|
+
background-color: var(--rp-code-title-bg);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.rp-codeblock__fold-btn__icon {
|
|
124
|
+
width: 18px;
|
|
125
|
+
height: 18px;
|
|
126
|
+
transition: transform .3s;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.rp-codeblock__fold-btn--expanded .rp-codeblock__fold-btn__icon {
|
|
130
|
+
transform: rotate(180deg);
|
|
131
|
+
}
|
|
132
|
+
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CodeButtonGroupProps } from '@theme';
|
|
1
|
+
import { type CodeButtonGroupProps } from '@rspress/core/theme';
|
|
2
2
|
import './index.scss';
|
|
3
3
|
export type CodeBlockProps = {
|
|
4
4
|
title?: string;
|
|
@@ -11,8 +11,16 @@ export type CodeBlockProps = {
|
|
|
11
11
|
* @default false
|
|
12
12
|
*/
|
|
13
13
|
lineNumbers?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
fold?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* @default 300
|
|
20
|
+
*/
|
|
21
|
+
height?: number;
|
|
14
22
|
containerElementClassName?: string;
|
|
15
|
-
codeButtonGroupProps?: Omit<CodeButtonGroupProps, 'preElementRef' | '
|
|
23
|
+
codeButtonGroupProps?: Omit<CodeButtonGroupProps, 'preElementRef' | 'wrapCode' | 'toggleWrapCode'>;
|
|
16
24
|
children?: React.ReactNode;
|
|
17
25
|
};
|
|
18
26
|
/**
|
|
@@ -51,4 +59,4 @@ export type CodeBlockProps = {
|
|
|
51
59
|
*</div>
|
|
52
60
|
*```
|
|
53
61
|
*/
|
|
54
|
-
export declare function CodeBlock({ containerElementClassName, title, lang, wrapCode: wrapCodeProp, lineNumbers: lineNumbersProp, codeButtonGroupProps, children, }: CodeBlockProps): import("react/jsx-runtime").JSX.Element;
|
|
62
|
+
export declare function CodeBlock({ containerElementClassName, title, lang, wrapCode: wrapCodeProp, lineNumbers: lineNumbersProp, fold, height, codeButtonGroupProps, children, }: CodeBlockProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,21 +1,55 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { CodeButtonGroup, useCodeButtonGroup } from "@theme";
|
|
2
|
+
import { CodeButtonGroup, IconArrowDown, SvgWrapper, useCodeButtonGroup } from "@rspress/core/theme";
|
|
3
3
|
import clsx from "clsx";
|
|
4
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
4
5
|
import "./index.css";
|
|
5
|
-
function CodeBlock({ containerElementClassName, title, lang = 'txt', wrapCode: wrapCodeProp = false, lineNumbers: lineNumbersProp = false, codeButtonGroupProps, children }) {
|
|
6
|
+
function CodeBlock({ containerElementClassName, title, lang = 'txt', wrapCode: wrapCodeProp = false, lineNumbers: lineNumbersProp = false, fold = false, height = 300, codeButtonGroupProps, children }) {
|
|
6
7
|
if (process.env.__SSR_MD__) return /*#__PURE__*/ jsx(Fragment, {
|
|
7
8
|
children: children
|
|
8
9
|
});
|
|
9
|
-
const {
|
|
10
|
+
const { wrapCode: wrapCodeState, toggleWrapCode, copyElementRef } = useCodeButtonGroup(wrapCodeProp);
|
|
11
|
+
const [expanded, setExpanded] = useState(false);
|
|
12
|
+
const [needFold, setNeedFold] = useState(false);
|
|
13
|
+
const codeBlockRef = useRef(null);
|
|
14
|
+
const contentRef = useRef(null);
|
|
15
|
+
useEffect(()=>{
|
|
16
|
+
if (!fold || !contentRef.current) return void setNeedFold(false);
|
|
17
|
+
const realHeight = contentRef.current.scrollHeight;
|
|
18
|
+
setNeedFold(realHeight > height);
|
|
19
|
+
}, [
|
|
20
|
+
fold,
|
|
21
|
+
height
|
|
22
|
+
]);
|
|
23
|
+
const handleFoldToggle = useCallback(()=>{
|
|
24
|
+
if (expanded) {
|
|
25
|
+
setExpanded(false);
|
|
26
|
+
requestAnimationFrame(()=>{
|
|
27
|
+
if (codeBlockRef.current) {
|
|
28
|
+
const rect = codeBlockRef.current.getBoundingClientRect();
|
|
29
|
+
if (rect.top < 0) window.scrollBy({
|
|
30
|
+
top: rect.top - 16,
|
|
31
|
+
behavior: 'smooth'
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
} else setExpanded(true);
|
|
36
|
+
}, [
|
|
37
|
+
expanded
|
|
38
|
+
]);
|
|
10
39
|
return /*#__PURE__*/ jsxs("div", {
|
|
11
40
|
className: clsx('rp-codeblock', `language-${lang}`, containerElementClassName),
|
|
41
|
+
ref: codeBlockRef,
|
|
12
42
|
children: [
|
|
13
43
|
title && /*#__PURE__*/ jsx("div", {
|
|
14
44
|
className: "rp-codeblock__title",
|
|
15
45
|
children: title
|
|
16
46
|
}),
|
|
17
47
|
/*#__PURE__*/ jsxs("div", {
|
|
18
|
-
className: clsx('rp-codeblock__content',
|
|
48
|
+
className: clsx('rp-codeblock__content', wrapCodeState && 'rp-codeblock__content--wrap-code', lineNumbersProp && 'rp-codeblock__content--line-numbers', needFold && !expanded && 'rp-codeblock__content--fold'),
|
|
49
|
+
style: needFold && !expanded ? {
|
|
50
|
+
maxHeight: `${height}px`
|
|
51
|
+
} : void 0,
|
|
52
|
+
ref: contentRef,
|
|
19
53
|
children: [
|
|
20
54
|
/*#__PURE__*/ jsx("div", {
|
|
21
55
|
className: "rp-codeblock__content__scroll-container rp-scrollbar rp-scrollbar--always",
|
|
@@ -25,10 +59,21 @@ function CodeBlock({ containerElementClassName, title, lang = 'txt', wrapCode: w
|
|
|
25
59
|
/*#__PURE__*/ jsx(CodeButtonGroup, {
|
|
26
60
|
...codeButtonGroupProps,
|
|
27
61
|
copyElementRef: copyElementRef,
|
|
28
|
-
|
|
29
|
-
|
|
62
|
+
wrapCode: wrapCodeState,
|
|
63
|
+
toggleWrapCode: toggleWrapCode
|
|
30
64
|
})
|
|
31
65
|
]
|
|
66
|
+
}),
|
|
67
|
+
needFold && /*#__PURE__*/ jsx("button", {
|
|
68
|
+
type: "button",
|
|
69
|
+
className: clsx('rp-codeblock__fold-btn', expanded && 'rp-codeblock__fold-btn--expanded'),
|
|
70
|
+
onClick: handleFoldToggle,
|
|
71
|
+
"aria-label": expanded ? 'Collapse code' : 'Expand code',
|
|
72
|
+
"aria-expanded": expanded,
|
|
73
|
+
children: /*#__PURE__*/ jsx(SvgWrapper, {
|
|
74
|
+
icon: IconArrowDown,
|
|
75
|
+
className: "rp-codeblock__fold-btn__icon"
|
|
76
|
+
})
|
|
32
77
|
})
|
|
33
78
|
]
|
|
34
79
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CodeBlockProps } from '@theme';
|
|
1
|
+
import type { CodeBlockProps } from '@rspress/core/theme';
|
|
2
2
|
import { type ReactNode } from 'react';
|
|
3
3
|
import { type BundledLanguage, type BundledTheme, type CodeToHastOptions } from 'shiki';
|
|
4
4
|
export interface CodeBlockRuntimeProps extends CodeBlockProps {
|
|
@@ -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, wrapCode, lineNumbers, }: CodeBlockRuntimeProps): ReactNode;
|
|
14
|
+
export declare function CodeBlockRuntime({ lang, title, code, shikiOptions, codeButtonGroupProps, children: _, containerElementClassName, onRendered, wrapCode, lineNumbers, fold, height, }: CodeBlockRuntimeProps): ReactNode;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { getCustomMDXComponent } from "@theme";
|
|
2
|
+
import { getCustomMDXComponent } from "@rspress/core/theme";
|
|
3
3
|
import { toJsxRuntime } from "hast-util-to-jsx-runtime";
|
|
4
4
|
import { Fragment, useEffect, useMemo, useRef, useState } from "react";
|
|
5
5
|
import { codeToHast, createCssVariablesTheme } from "shiki";
|
|
@@ -14,7 +14,7 @@ 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, wrapCode, lineNumbers }) {
|
|
17
|
+
function CodeBlockRuntime({ lang, title, code, shikiOptions, codeButtonGroupProps, children: _, containerElementClassName, onRendered, wrapCode, lineNumbers, fold, height }) {
|
|
18
18
|
const mdxComponents = useMemo(()=>getCustomMDXComponent(), []);
|
|
19
19
|
const { pre: ShikiPre, code: Code, ...otherMdxComponents } = mdxComponents;
|
|
20
20
|
const fallback = useMemo(()=>/*#__PURE__*/ jsx(ShikiPre, {
|
|
@@ -22,6 +22,8 @@ function CodeBlockRuntime({ lang, title, code, shikiOptions, codeButtonGroupProp
|
|
|
22
22
|
lang: lang,
|
|
23
23
|
wrapCode: wrapCode,
|
|
24
24
|
lineNumbers: lineNumbers,
|
|
25
|
+
fold: fold,
|
|
26
|
+
height: height,
|
|
25
27
|
containerElementClassName: containerElementClassName,
|
|
26
28
|
codeButtonGroupProps: codeButtonGroupProps,
|
|
27
29
|
className: "shiki css-variables",
|
|
@@ -36,6 +38,8 @@ function CodeBlockRuntime({ lang, title, code, shikiOptions, codeButtonGroupProp
|
|
|
36
38
|
lang,
|
|
37
39
|
wrapCode,
|
|
38
40
|
lineNumbers,
|
|
41
|
+
fold,
|
|
42
|
+
height,
|
|
39
43
|
containerElementClassName,
|
|
40
44
|
codeButtonGroupProps,
|
|
41
45
|
code
|
|
@@ -63,6 +67,8 @@ function CodeBlockRuntime({ lang, title, code, shikiOptions, codeButtonGroupProp
|
|
|
63
67
|
codeButtonGroupProps: codeButtonGroupProps,
|
|
64
68
|
wrapCode: wrapCode,
|
|
65
69
|
lineNumbers: lineNumbers,
|
|
70
|
+
fold: fold,
|
|
71
|
+
height: height,
|
|
66
72
|
...props
|
|
67
73
|
}),
|
|
68
74
|
code: (props)=>/*#__PURE__*/ jsx(Code, {
|
|
@@ -80,6 +86,8 @@ function CodeBlockRuntime({ lang, title, code, shikiOptions, codeButtonGroupProp
|
|
|
80
86
|
containerElementClassName,
|
|
81
87
|
lang,
|
|
82
88
|
lineNumbers,
|
|
89
|
+
fold,
|
|
90
|
+
height,
|
|
83
91
|
shikiOptions,
|
|
84
92
|
title,
|
|
85
93
|
wrapCode
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { IconCopy, IconSuccess, SvgWrapper } from "@theme";
|
|
2
|
+
import { IconCopy, IconSuccess, SvgWrapper } from "@rspress/core/theme";
|
|
3
3
|
import copy_to_clipboard from "copy-to-clipboard";
|
|
4
4
|
import { useRef } from "react";
|
|
5
5
|
import "./CopyCodeButton.css";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import './index.scss';
|
|
2
2
|
export interface CodeButtonGroupProps {
|
|
3
3
|
copyElementRef: React.RefObject<HTMLDivElement | null>;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
wrapCode: boolean;
|
|
5
|
+
toggleWrapCode: () => void;
|
|
6
6
|
/**
|
|
7
7
|
* @default true
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
showWrapCodeButton?: boolean;
|
|
10
10
|
/**
|
|
11
11
|
* @default true
|
|
12
12
|
*/
|
|
@@ -14,7 +14,7 @@ export interface CodeButtonGroupProps {
|
|
|
14
14
|
}
|
|
15
15
|
export declare const useCodeButtonGroup: (initialWrapCode?: boolean) => {
|
|
16
16
|
copyElementRef: import("react").RefObject<HTMLDivElement | null>;
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
wrapCode: boolean;
|
|
18
|
+
toggleWrapCode: () => void;
|
|
19
19
|
};
|
|
20
|
-
export declare function CodeButtonGroup({
|
|
20
|
+
export declare function CodeButtonGroup({ wrapCode, toggleWrapCode, copyElementRef, showWrapCodeButton, showCopyButton, }: CodeButtonGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useSite } from "@rspress/core/runtime";
|
|
3
|
-
import { IconWrap, IconWrapped, SvgWrapper } from "@theme";
|
|
3
|
+
import { IconWrap, IconWrapped, SvgWrapper } from "@rspress/core/theme";
|
|
4
4
|
import clsx from "clsx";
|
|
5
5
|
import { useRef, useState } from "react";
|
|
6
6
|
import "./index.css";
|
|
@@ -8,25 +8,25 @@ import { CopyCodeButton } from "./CopyCodeButton.js";
|
|
|
8
8
|
const useCodeButtonGroup = (initialWrapCode)=>{
|
|
9
9
|
const { site } = useSite();
|
|
10
10
|
const { defaultWrapCode } = site.markdown;
|
|
11
|
-
const [
|
|
11
|
+
const [wrapCode, setWrapCode] = useState(initialWrapCode ?? defaultWrapCode);
|
|
12
12
|
const copyElementRef = useRef(null);
|
|
13
|
-
const
|
|
14
|
-
|
|
13
|
+
const toggleWrapCode = ()=>{
|
|
14
|
+
setWrapCode(!wrapCode);
|
|
15
15
|
};
|
|
16
16
|
return {
|
|
17
17
|
copyElementRef,
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
wrapCode,
|
|
19
|
+
toggleWrapCode
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
|
-
function CodeButtonGroup({
|
|
22
|
+
function CodeButtonGroup({ wrapCode, toggleWrapCode, copyElementRef, showWrapCodeButton = true, showCopyButton = true }) {
|
|
23
23
|
return /*#__PURE__*/ jsx(Fragment, {
|
|
24
24
|
children: /*#__PURE__*/ jsxs("div", {
|
|
25
25
|
className: "rp-code-button-group",
|
|
26
26
|
children: [
|
|
27
|
-
|
|
28
|
-
className: clsx('rp-code-button-group__button', 'rp-code-wrap-button',
|
|
29
|
-
onClick: ()=>
|
|
27
|
+
showWrapCodeButton && /*#__PURE__*/ jsxs("button", {
|
|
28
|
+
className: clsx('rp-code-button-group__button', 'rp-code-wrap-button', wrapCode && 'rp-code-wrap-button--wrapped'),
|
|
29
|
+
onClick: ()=>toggleWrapCode(),
|
|
30
30
|
title: "Toggle code wrap",
|
|
31
31
|
children: [
|
|
32
32
|
/*#__PURE__*/ jsx(SvgWrapper, {
|