@rspress/core 2.0.0-rc.4 → 2.0.0-rc.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{0~7675.723d12b2.js → 0~7675.d236b058.js} +3 -3
- package/dist/{5485.9fc7f63d.js → 5485.7586c86a.js} +1 -1
- package/dist/{3521.9eb6b114.js → 7786.421b464f.js} +2 -2
- package/dist/9348.1beb3e25.js +11 -0
- package/dist/_private/react/render.js +1 -1
- package/dist/cli/index.js +2 -2
- package/dist/config/defineConfig.d.ts +40 -0
- package/dist/{cli/config → config}/loadConfigFile.js +2 -2
- package/dist/eject-theme/components/Callout/index.scss +6 -6
- package/dist/eject-theme/components/CodeBlock/index.tsx +1 -1
- package/dist/eject-theme/components/DocContent/docComponents/title.tsx +21 -2
- package/dist/eject-theme/components/FallbackHeading/index.tsx +4 -0
- package/dist/eject-theme/components/HomeBackground/useNavTransparent.tsx +2 -1
- package/dist/eject-theme/components/HomeHero/index.scss +8 -0
- package/dist/eject-theme/components/HomeHero/index.tsx +11 -2
- package/dist/eject-theme/components/Llms/LlmsContainer.scss +6 -0
- package/dist/eject-theme/components/Llms/LlmsContainer.tsx +9 -0
- package/dist/eject-theme/components/Llms/LlmsCopyButton.scss +57 -0
- package/dist/eject-theme/components/Llms/LlmsCopyButton.tsx +94 -0
- package/dist/eject-theme/components/Llms/LlmsViewOptions.scss +98 -0
- package/dist/eject-theme/components/Llms/LlmsViewOptions.tsx +259 -0
- package/dist/eject-theme/components/Llms/index.scss +42 -0
- package/dist/eject-theme/components/Llms/index.tsx +4 -0
- package/dist/eject-theme/components/Llms/useMdUrl.ts +14 -0
- package/dist/eject-theme/components/Nav/index.scss +3 -0
- package/dist/eject-theme/components/Nav/index.tsx +7 -2
- package/dist/eject-theme/components/{Nav/NavTitle.tsx → NavTitle/index.tsx} +15 -6
- package/dist/eject-theme/components/Overview/index.tsx +8 -62
- package/dist/eject-theme/components/OverviewGroup/index.tsx +46 -0
- package/dist/eject-theme/components/Steps/index.scss +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -4
- package/dist/node/PluginDriver.js +1 -1
- package/dist/node/auto-nav-sidebar/index.js +1 -1
- package/dist/node/auto-nav-sidebar/normalize.js +1 -1
- package/dist/node/auto-nav-sidebar/utils.js +1 -1
- package/dist/node/auto-nav-sidebar/walk.js +1 -1
- package/dist/node/constants.js +1 -1
- package/dist/node/eject.js +1 -0
- package/dist/node/initRsbuild.js +6 -6
- package/dist/node/last-updated/index.js +1 -1
- package/dist/node/mdx/{loader.7c249a26.js → loader.15e0b2d2.js} +0 -5
- package/dist/node/mdx/options.js +2 -2
- package/dist/node/mdx/processor.js +1 -1
- package/dist/node/mdx/rehypePlugins/codeMeta.js +1 -1
- package/dist/node/mdx/rehypePlugins/headerAnchor.js +2 -3
- package/dist/node/mdx/rehypePlugins/shiki.js +1 -1
- package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +1 -2
- package/dist/node/mdx/remarkPlugins/image.js +1 -3
- package/dist/node/mdx/remarkPlugins/link.js +1 -2
- package/dist/node/mdx/remarkPlugins/toc.d.ts +4 -3
- package/dist/node/mdx/remarkPlugins/toc.js +14 -11
- package/dist/node/route/RoutePage.d.ts +3 -1
- package/dist/node/route/RoutePage.js +4 -0
- package/dist/node/route/RouteService.js +2 -2
- package/dist/node/route/extractPageData.d.ts +5 -0
- package/dist/node/route/extractPageData.js +88 -58
- package/dist/node/route/normalizeRoutePath.js +2 -2
- package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.d.ts +21 -0
- package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.js +21 -0
- package/dist/node/runtimeModule/i18n.js +4 -3
- package/dist/node/runtimeModule/pageData/createPageData.js +9 -6
- package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +20 -14
- package/dist/node/runtimeModule/siteData/createSiteData.js +2 -1
- package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
- package/dist/node/serve.js +1 -1
- package/dist/node/ssg/renderPage.js +1 -1
- package/dist/node/ssg/renderPageWorker.js +1 -1
- package/dist/node/ssg/renderPages.js +7 -3
- package/dist/node/ssg/rsbuildPluginSSG.js +1 -1
- package/dist/node/ssg/ssgEnv.js +1 -1
- package/dist/node/ssg-md/llms/emitLlmsTxt.js +2 -2
- package/dist/node/ssg-md/llms/llmsTxt.js +12 -2
- package/dist/node/ssg-md/remarkSplitMdx.js +2 -2
- package/dist/node/ssg-md/renderPage.js +1 -1
- package/dist/node/ssg-md/renderPages.js +1 -1
- package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -1
- package/dist/node/utils/createHash.js +1 -1
- package/dist/node/utils/flattenMdxContent.js +2 -3
- package/dist/node/utils/getPageKey.js +1 -1
- package/dist/node/utils/normalizePath.js +1 -1
- package/dist/node/utils/reactAlias.js +1 -1
- package/dist/runtime/Content.d.ts +4 -0
- package/dist/runtime/Content.js +18 -0
- package/dist/runtime/NoSSR.d.ts +3 -0
- package/dist/runtime/NoSSR.js +14 -0
- package/dist/runtime/getSidebarDataGroup.test.js +68 -0
- package/dist/runtime/hooks/useActiveMatcher.d.ts +1 -0
- package/dist/runtime/hooks/useActiveMatcher.js +14 -0
- package/dist/runtime/hooks/useDark.d.ts +7 -0
- package/dist/runtime/hooks/useDark.js +7 -0
- package/dist/runtime/hooks/useFrontmatter.d.ts +4 -0
- package/dist/runtime/hooks/useFrontmatter.js +9 -0
- package/dist/runtime/hooks/useI18n.d.ts +2 -0
- package/dist/runtime/hooks/useI18n.js +14 -0
- package/dist/runtime/hooks/useLang.d.ts +1 -0
- package/dist/runtime/hooks/useLang.js +6 -0
- package/dist/runtime/hooks/useLocaleSiteData.d.ts +18 -0
- package/dist/runtime/hooks/useLocaleSiteData.js +20 -0
- package/dist/runtime/hooks/useNav.d.ts +1 -0
- package/dist/runtime/hooks/useNav.js +12 -0
- package/dist/runtime/hooks/usePage.d.ts +10 -0
- package/dist/runtime/hooks/usePage.js +9 -0
- package/dist/runtime/hooks/usePageData.d.ts +5 -0
- package/dist/runtime/hooks/usePageData.js +16 -0
- package/dist/runtime/hooks/usePages.d.ts +4 -0
- package/dist/runtime/hooks/usePages.js +7 -0
- package/dist/runtime/hooks/useSidebar.d.ts +16 -0
- package/dist/runtime/hooks/useSidebar.js +67 -0
- package/dist/runtime/hooks/useSite.d.ts +4 -0
- package/dist/runtime/hooks/useSite.js +7 -0
- package/dist/runtime/hooks/useVersion.d.ts +1 -0
- package/dist/runtime/hooks/useVersion.js +6 -0
- package/dist/runtime/hooks/useWindowSize.d.ts +9 -0
- package/dist/runtime/hooks/useWindowSize.js +31 -0
- package/dist/runtime/hooks/useWindowSize.test.js +36 -0
- package/dist/runtime/index.d.ts +21 -0
- package/dist/runtime/index.js +22 -0
- package/dist/runtime/route.d.ts +36 -0
- package/dist/runtime/route.js +53 -0
- package/dist/runtime/route.test.js +154 -0
- package/dist/runtime/ssrMdServerEntry.js +1 -1
- package/dist/runtime/utils.d.ts +12 -0
- package/dist/runtime/utils.js +34 -0
- package/dist/runtime/utils.test.js +34 -0
- package/dist/theme/components/Callout/index.css +6 -6
- package/dist/theme/components/CodeBlock/index.js +1 -1
- package/dist/theme/components/DocContent/docComponents/title.js +25 -5
- package/dist/theme/components/FallbackHeading/index.js +4 -1
- package/dist/theme/components/HomeBackground/useNavTransparent.js +1 -1
- package/dist/theme/components/HomeHero/index.css +16 -10
- package/dist/theme/components/HomeHero/index.js +10 -3
- package/dist/theme/components/Llms/LlmsContainer.css +7 -0
- package/dist/theme/components/Llms/LlmsContainer.d.ts +5 -0
- package/dist/theme/components/Llms/LlmsContainer.js +9 -0
- package/dist/theme/components/Llms/LlmsCopyButton.css +57 -0
- package/dist/theme/components/Llms/LlmsCopyButton.d.ts +20 -0
- package/dist/theme/components/Llms/LlmsCopyButton.js +73 -0
- package/dist/theme/components/Llms/LlmsCopyButton.js.LICENSE.txt +5 -0
- package/dist/theme/components/Llms/LlmsViewOptions.css +93 -0
- package/dist/theme/components/Llms/LlmsViewOptions.d.ts +34 -0
- package/dist/theme/components/Llms/LlmsViewOptions.js +206 -0
- package/dist/theme/components/Llms/LlmsViewOptions.js.LICENSE.txt +5 -0
- package/dist/theme/components/Llms/index.css +32 -0
- package/dist/theme/components/Llms/index.d.ts +4 -0
- package/dist/theme/components/Llms/index.js +5 -0
- package/dist/theme/components/Llms/useMdUrl.d.ts +6 -0
- package/dist/theme/components/Llms/useMdUrl.js +15 -0
- package/dist/theme/components/Nav/index.css +1 -0
- package/dist/theme/components/Nav/index.js +1 -2
- package/dist/theme/components/{Nav/NavTitle.d.ts → NavTitle/index.d.ts} +1 -1
- package/dist/theme/components/{Nav/NavTitle.js → NavTitle/index.js} +11 -6
- package/dist/theme/components/Overview/index.js +11 -43
- package/dist/theme/components/OverviewGroup/index.js +33 -0
- package/dist/theme/components/PageTabs/index.css +1 -1
- package/dist/theme/components/Steps/index.css +1 -0
- package/dist/theme/components/Tabs/index.css +4 -4
- package/dist/theme/hooks/useDynamicToc.d.ts +2 -0
- package/dist/theme/hooks/useDynamicToc.js +3 -1
- package/dist/theme/index.d.ts +3 -1
- package/dist/theme/index.js +4 -2
- package/dist/theme/layout/Layout/index.js +1 -1
- package/dist/theme/logic/useScrollAfterNav.js +2 -2
- package/dist/theme/logic/useScrollReset.js +2 -2
- package/dist/theme/logic/{useAppearance.d.ts → useThemeState.d.ts} +4 -1
- package/dist/theme/logic/useThemeState.js +50 -0
- package/dist/theme/styles/scrollbar.css +14 -2
- package/package.json +18 -20
- package/static/MediumZoom.tsx +1 -1
- package/dist/4669.69cb6b18.js +0 -1
- package/dist/8813.4b28f4bb.js +0 -1
- package/dist/9643.2dff683e.js +0 -4
- package/dist/cli/config/index.d.ts +0 -2
- package/dist/runtime.72d450ac.js +0 -1
- package/dist/runtime.d.ts +0 -2
- package/dist/runtime.js +0 -3
- package/dist/theme/logic/useAppearance.js +0 -64
- /package/dist/{cli/config/index.js → config/defineConfig.js} +0 -0
- /package/dist/{cli/config → config}/loadConfigFile.d.ts +0 -0
- /package/dist/eject-theme/components/{Nav/NavTitle.scss → NavTitle/index.scss} +0 -0
- /package/dist/theme/components/{Nav/NavTitle.css → NavTitle/index.css} +0 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useLayoutEffect, useState } from "react";
|
|
2
|
+
const RESIZE_DEBOUNCE_MS = 150;
|
|
3
|
+
function useWindowSize(initialWidth, initialHeight) {
|
|
4
|
+
const [size, setSize] = useState({
|
|
5
|
+
width: initialWidth ?? 1 / 0,
|
|
6
|
+
height: initialHeight ?? 1 / 0
|
|
7
|
+
});
|
|
8
|
+
useLayoutEffect(()=>{
|
|
9
|
+
let timeoutId = null;
|
|
10
|
+
const handleResize = ()=>{
|
|
11
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
12
|
+
timeoutId = setTimeout(()=>{
|
|
13
|
+
setSize({
|
|
14
|
+
width: window.innerWidth,
|
|
15
|
+
height: window.innerHeight
|
|
16
|
+
});
|
|
17
|
+
}, RESIZE_DEBOUNCE_MS);
|
|
18
|
+
};
|
|
19
|
+
setSize({
|
|
20
|
+
width: window.innerWidth,
|
|
21
|
+
height: window.innerHeight
|
|
22
|
+
});
|
|
23
|
+
window.addEventListener('resize', handleResize);
|
|
24
|
+
return ()=>{
|
|
25
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
26
|
+
window.removeEventListener('resize', handleResize);
|
|
27
|
+
};
|
|
28
|
+
}, []);
|
|
29
|
+
return size;
|
|
30
|
+
}
|
|
31
|
+
export { useWindowSize };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { describe, expect, it } from "@rstest/core";
|
|
4
|
+
describe('useWindowSize', ()=>{
|
|
5
|
+
it('should have debounce implementation with RESIZE_DEBOUNCE_MS constant', ()=>{
|
|
6
|
+
const filePath = join(__dirname, 'useWindowSize.ts');
|
|
7
|
+
const fileContent = readFileSync(filePath, 'utf-8');
|
|
8
|
+
expect(fileContent).toContain('const RESIZE_DEBOUNCE_MS = 150');
|
|
9
|
+
expect(fileContent).toContain('setTimeout');
|
|
10
|
+
expect(fileContent).toContain('RESIZE_DEBOUNCE_MS');
|
|
11
|
+
});
|
|
12
|
+
it('should clear timeout with conditional check', ()=>{
|
|
13
|
+
const filePath = join(__dirname, 'useWindowSize.ts');
|
|
14
|
+
const fileContent = readFileSync(filePath, 'utf-8');
|
|
15
|
+
expect(fileContent).toContain('if (timeoutId) clearTimeout(timeoutId)');
|
|
16
|
+
expect(fileContent).not.toContain('clearTimeout(timeoutId!)');
|
|
17
|
+
});
|
|
18
|
+
it('should register and cleanup resize event listener', ()=>{
|
|
19
|
+
const filePath = join(__dirname, 'useWindowSize.ts');
|
|
20
|
+
const fileContent = readFileSync(filePath, 'utf-8');
|
|
21
|
+
expect(fileContent).toContain("addEventListener('resize'");
|
|
22
|
+
expect(fileContent).toContain("removeEventListener('resize'");
|
|
23
|
+
});
|
|
24
|
+
it('should set initial size immediately', ()=>{
|
|
25
|
+
const filePath = join(__dirname, 'useWindowSize.ts');
|
|
26
|
+
const fileContent = readFileSync(filePath, 'utf-8');
|
|
27
|
+
const setStateMatch = fileContent.match(/setSize\(\{[^}]+\}\)/g);
|
|
28
|
+
expect(setStateMatch).toBeTruthy();
|
|
29
|
+
expect(setStateMatch?.length).toBeGreaterThanOrEqual(2);
|
|
30
|
+
});
|
|
31
|
+
it('should export useWindowSize function', async ()=>{
|
|
32
|
+
const module = await import("./useWindowSize.js");
|
|
33
|
+
expect(module.useWindowSize).toBeDefined();
|
|
34
|
+
expect(typeof module.useWindowSize).toBe('function');
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export { isDataUrl, isExternalUrl, matchNavbar, matchSidebar, normalizeHref, } from '@rspress/shared';
|
|
2
|
+
export { Head } from '@unhead/react';
|
|
3
|
+
export * from 'react-router-dom';
|
|
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';
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
export * from "react-router-dom";
|
|
22
|
+
export { Content, Head, NoSSR, PageContext, ThemeContext, addLeadingSlash, addTrailingSlash, cleanUrlByConfig, getSidebarDataGroup, isActive, isDataUrl, isEqualPath, isExternalUrl, isProduction, matchNavbar, matchSidebar, normalizeHref, normalizeHrefInRuntime, normalizeImagePath, pathnameToRouteService, preloadLink, removeBase, removeTrailingSlash, routePathToMdPath, useActiveMatcher, useDark, useFrontmatter, useI18n, useLang, useLocaleSiteData, useNav, usePage, usePageData, usePages, useSidebar, useSidebarDynamic, useSite, useVersion, useWindowSize, withBase };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Route } from '@rspress/shared';
|
|
2
|
+
/**
|
|
3
|
+
* Simple implementation of matchPath to check if a pattern matches a pathname
|
|
4
|
+
* Better performance alternative of `import { matchPath } from 'react-router-dom'`
|
|
5
|
+
* @param pattern - The route pattern to match against
|
|
6
|
+
* @param pathname - The pathname to check
|
|
7
|
+
* @returns Match object if matched, null otherwise
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* matchPath('/api/config', '/api/config') // { path: '/api/config' }
|
|
11
|
+
* matchPath('/api/config/', '/api/config') // { path: '/api/config/' }
|
|
12
|
+
* matchPath('/api/config', '/api/other') // null
|
|
13
|
+
*/
|
|
14
|
+
export declare function matchPath(pattern: string, pathname: string): {
|
|
15
|
+
path: string;
|
|
16
|
+
} | null;
|
|
17
|
+
/**
|
|
18
|
+
* this is a bridge of two core features Sidebar and RouteService
|
|
19
|
+
* @param pathname useLocation().pathname
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
export declare function pathnameToRouteService(pathname: string): Route | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* link: /api/config
|
|
25
|
+
* currentPathname:
|
|
26
|
+
* 0. /api/config
|
|
27
|
+
* 1. /api/config.html
|
|
28
|
+
* 2. /api/config/
|
|
29
|
+
* 3. /api/config/index
|
|
30
|
+
* 4. /api/config/index.html
|
|
31
|
+
* @param itemLink
|
|
32
|
+
* @param currentPathname
|
|
33
|
+
* @returns
|
|
34
|
+
*/
|
|
35
|
+
export declare function isActive(itemLink: string, currentPathname: string): boolean;
|
|
36
|
+
export declare const preloadLink: (link: string) => void;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { cleanUrl } from "@rspress/shared";
|
|
2
|
+
import { routes } from "virtual-routes";
|
|
3
|
+
function normalizeRoutePath(routePath) {
|
|
4
|
+
return cleanUrl(decodeURIComponent(routePath)).replace(/\.html$/, '').replace(/\/index$/, '/').toLowerCase();
|
|
5
|
+
}
|
|
6
|
+
function matchPath(pattern, pathname) {
|
|
7
|
+
const normalizedPattern = normalizeRoutePath(pattern);
|
|
8
|
+
const normalizedPathname = normalizeRoutePath(pathname);
|
|
9
|
+
const normalizedPatternWithSlash = normalizedPattern.endsWith('/') ? normalizedPattern : `${normalizedPattern}/`;
|
|
10
|
+
const normalizedPathnameWithSlash = normalizedPathname.endsWith('/') ? normalizedPathname : `${normalizedPathname}/`;
|
|
11
|
+
if (normalizedPatternWithSlash === normalizedPathnameWithSlash) return {
|
|
12
|
+
path: pattern
|
|
13
|
+
};
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const sortedRoutes = [
|
|
17
|
+
...routes
|
|
18
|
+
].sort((a, b)=>{
|
|
19
|
+
const pathA = a.path || '';
|
|
20
|
+
const pathB = b.path || '';
|
|
21
|
+
return pathB.length - pathA.length;
|
|
22
|
+
});
|
|
23
|
+
function matchRoutes(_routes, pathname) {
|
|
24
|
+
for (const route of sortedRoutes){
|
|
25
|
+
const routePath = route.path || '';
|
|
26
|
+
const match = matchPath(routePath, pathname);
|
|
27
|
+
if (match) return [
|
|
28
|
+
{
|
|
29
|
+
route
|
|
30
|
+
}
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
const cache = new Map();
|
|
36
|
+
function pathnameToRouteService(pathname) {
|
|
37
|
+
const normalizedPathname = normalizeRoutePath(pathname);
|
|
38
|
+
const cacheItem = cache.get(normalizedPathname);
|
|
39
|
+
if (cacheItem) return cacheItem;
|
|
40
|
+
const matched = matchRoutes(routes, normalizedPathname);
|
|
41
|
+
const route = matched?.[0]?.route;
|
|
42
|
+
if (route) cache.set(normalizedPathname, route);
|
|
43
|
+
return route;
|
|
44
|
+
}
|
|
45
|
+
function isActive(itemLink, currentPathname) {
|
|
46
|
+
const linkMatched = matchPath(itemLink, currentPathname);
|
|
47
|
+
return null !== linkMatched;
|
|
48
|
+
}
|
|
49
|
+
const preloadLink = (link)=>{
|
|
50
|
+
const route = pathnameToRouteService(link);
|
|
51
|
+
if (route) route.preload();
|
|
52
|
+
};
|
|
53
|
+
export { isActive, matchPath, pathnameToRouteService, preloadLink };
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { describe, expect, it, rs } from "@rstest/core";
|
|
2
|
+
import { isActive, matchPath, pathnameToRouteService } from "./route.js";
|
|
3
|
+
rs.mock('virtual-routes', ()=>{
|
|
4
|
+
const element = rs.fn();
|
|
5
|
+
const routes = [
|
|
6
|
+
{
|
|
7
|
+
path: '/api/config',
|
|
8
|
+
element,
|
|
9
|
+
filePath: 'api/config.mdx',
|
|
10
|
+
preload: async ()=>{},
|
|
11
|
+
lang: '',
|
|
12
|
+
version: ''
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
path: '/api/config/',
|
|
16
|
+
element,
|
|
17
|
+
filePath: 'api/config/index.mdx',
|
|
18
|
+
preload: async ()=>{},
|
|
19
|
+
lang: '',
|
|
20
|
+
version: ''
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
path: '/',
|
|
24
|
+
element,
|
|
25
|
+
filePath: 'index.mdx',
|
|
26
|
+
preload: async ()=>{},
|
|
27
|
+
lang: '',
|
|
28
|
+
version: ''
|
|
29
|
+
}
|
|
30
|
+
];
|
|
31
|
+
return {
|
|
32
|
+
routes
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
describe('matchPath', ()=>{
|
|
36
|
+
it('should match exact paths', ()=>{
|
|
37
|
+
expect(matchPath('/api/config', '/api/config')).toEqual({
|
|
38
|
+
path: '/api/config'
|
|
39
|
+
});
|
|
40
|
+
expect(matchPath('/api/config/', '/api/config/')).toEqual({
|
|
41
|
+
path: '/api/config/'
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
it('should normalize trailing slashes', ()=>{
|
|
45
|
+
expect(matchPath('/api/config', '/api/config/')).toEqual({
|
|
46
|
+
path: '/api/config'
|
|
47
|
+
});
|
|
48
|
+
expect(matchPath('/api/config/', '/api/config')).toEqual({
|
|
49
|
+
path: '/api/config/'
|
|
50
|
+
});
|
|
51
|
+
expect(matchPath('/api/config/', '/api/config/index.html')).toEqual({
|
|
52
|
+
path: '/api/config/'
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
it('should return null for non-matching paths', ()=>{
|
|
56
|
+
expect(matchPath('/api/config', '/api/other')).toBeNull();
|
|
57
|
+
expect(matchPath('/api', '/api/config')).toBeNull();
|
|
58
|
+
expect(matchPath('/api', '/api/index.md')).toBeNull();
|
|
59
|
+
});
|
|
60
|
+
it('should handle case-insensitive matching', ()=>{
|
|
61
|
+
expect(matchPath('/api/config', '/API/CONFIG')).toEqual({
|
|
62
|
+
path: '/api/config'
|
|
63
|
+
});
|
|
64
|
+
expect(matchPath('/api/config', '/Api/Config')).toEqual({
|
|
65
|
+
path: '/api/config'
|
|
66
|
+
});
|
|
67
|
+
expect(matchPath('/api/config', '/api/CONFIG.html')).toEqual({
|
|
68
|
+
path: '/api/config'
|
|
69
|
+
});
|
|
70
|
+
expect(matchPath('/api/config/', '/API/CONFIG/')).toEqual({
|
|
71
|
+
path: '/api/config/'
|
|
72
|
+
});
|
|
73
|
+
expect(matchPath('/api/config/', '/API/CONFIG/index.html')).toEqual({
|
|
74
|
+
path: '/api/config/'
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
describe('isActive', ()=>{
|
|
79
|
+
it('should return true for matching normalized paths', ()=>{
|
|
80
|
+
expect(isActive('/api/config', '/api/config')).toBe(true);
|
|
81
|
+
expect(isActive('/api/config', '/api/config.html')).toBe(true);
|
|
82
|
+
expect(isActive('/api/config', '/api/config/')).toBe(true);
|
|
83
|
+
});
|
|
84
|
+
it('should return false for non-matching paths', ()=>{
|
|
85
|
+
expect(isActive('/api/config', '/api/other')).toBe(false);
|
|
86
|
+
});
|
|
87
|
+
it('should handle hash and search parameters correctly', ()=>{
|
|
88
|
+
expect(isActive('/api/config', '/api/config#hash')).toBe(true);
|
|
89
|
+
expect(isActive('/api/config', '/api/config?query=value')).toBe(true);
|
|
90
|
+
expect(isActive('/api/config', '/api/config.html#hash')).toBe(true);
|
|
91
|
+
expect(isActive('/api/config', '/api/config.html?query=value')).toBe(true);
|
|
92
|
+
expect(isActive('/api/config', '/api/config.html?query=value#hash')).toBe(true);
|
|
93
|
+
expect(isActive('/api/config#different', '/api/config#hash')).toBe(true);
|
|
94
|
+
});
|
|
95
|
+
it('should handle case-insensitive matching', ()=>{
|
|
96
|
+
expect(isActive('/api/config', '/API/CONFIG')).toBe(true);
|
|
97
|
+
expect(isActive('/api/config', '/Api/Config')).toBe(true);
|
|
98
|
+
expect(isActive('/api/config', '/api/CONFIG.html')).toBe(true);
|
|
99
|
+
expect(isActive('/api/config', '/API/CONFIG/')).toBe(true);
|
|
100
|
+
expect(isActive('/api/config', '/API/CONFIG/index.html')).toBe(true);
|
|
101
|
+
expect(isActive('/api/config', '/api/CONFIG#hash')).toBe(true);
|
|
102
|
+
expect(isActive('/api/config', '/API/config?query=value')).toBe(true);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
describe('pathnameToRouteService', ()=>{
|
|
106
|
+
it('0. /api/config', ()=>{
|
|
107
|
+
const pathname = '/api/config';
|
|
108
|
+
expect(pathnameToRouteService(pathname)?.path).toMatchInlineSnapshot('"/api/config/"');
|
|
109
|
+
});
|
|
110
|
+
it('1. /api/config.html', ()=>{
|
|
111
|
+
const pathname = '/api/config.html';
|
|
112
|
+
expect(pathnameToRouteService(pathname)?.path).toMatchInlineSnapshot('"/api/config/"');
|
|
113
|
+
});
|
|
114
|
+
it('2. /api/config/', ()=>{
|
|
115
|
+
const pathname = '/api/config/';
|
|
116
|
+
expect(pathnameToRouteService(pathname)?.path).toMatchInlineSnapshot('"/api/config/"');
|
|
117
|
+
});
|
|
118
|
+
it('3. /api/config/index', ()=>{
|
|
119
|
+
const pathname = '/api/config/index';
|
|
120
|
+
expect(pathnameToRouteService(pathname)?.path).toMatchInlineSnapshot('"/api/config/"');
|
|
121
|
+
});
|
|
122
|
+
it('4. /api/config/index.html', ()=>{
|
|
123
|
+
const pathname = '/api/config/index.html';
|
|
124
|
+
expect(pathnameToRouteService(pathname)?.path).toMatchInlineSnapshot('"/api/config/"');
|
|
125
|
+
});
|
|
126
|
+
it('5. /', ()=>{
|
|
127
|
+
expect(pathnameToRouteService('/index.html')?.path).toMatchInlineSnapshot('"/"');
|
|
128
|
+
expect(pathnameToRouteService('/index.md')?.path).toMatchInlineSnapshot("undefined");
|
|
129
|
+
});
|
|
130
|
+
it('6. /api/config.html#hash - should handle hash correctly', ()=>{
|
|
131
|
+
const pathname = '/api/config.html#hash';
|
|
132
|
+
expect(pathnameToRouteService(pathname)?.path).toMatchInlineSnapshot('"/api/config/"');
|
|
133
|
+
});
|
|
134
|
+
it('7. /api/config.html?query=value - should handle query params correctly', ()=>{
|
|
135
|
+
const pathname = '/api/config.html?query=value';
|
|
136
|
+
expect(pathnameToRouteService(pathname)?.path).toMatchInlineSnapshot('"/api/config/"');
|
|
137
|
+
});
|
|
138
|
+
it('8. /api/config.html?query=value#hash - should handle both query and hash', ()=>{
|
|
139
|
+
const pathname = '/api/config.html?query=value#hash';
|
|
140
|
+
expect(pathnameToRouteService(pathname)?.path).toMatchInlineSnapshot('"/api/config/"');
|
|
141
|
+
});
|
|
142
|
+
it('9. /api/config#hash - should handle hash without .html', ()=>{
|
|
143
|
+
const pathname = '/api/config#hash';
|
|
144
|
+
expect(pathnameToRouteService(pathname)?.path).toMatchInlineSnapshot('"/api/config/"');
|
|
145
|
+
});
|
|
146
|
+
it('10. Case-insensitive route matching', ()=>{
|
|
147
|
+
expect(pathnameToRouteService('/API/CONFIG')?.path).toMatchInlineSnapshot('"/api/config/"');
|
|
148
|
+
expect(pathnameToRouteService('/Api/Config')?.path).toMatchInlineSnapshot('"/api/config/"');
|
|
149
|
+
expect(pathnameToRouteService('/API/CONFIG.html')?.path).toMatchInlineSnapshot('"/api/config/"');
|
|
150
|
+
expect(pathnameToRouteService('/API/CONFIG/')?.path).toMatchInlineSnapshot('"/api/config/"');
|
|
151
|
+
expect(pathnameToRouteService('/API/CONFIG/index.html')?.path).toMatchInlineSnapshot('"/api/config/"');
|
|
152
|
+
expect(pathnameToRouteService('/api/CONFIG#hash')?.path).toMatchInlineSnapshot('"/api/config/"');
|
|
153
|
+
});
|
|
154
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { renderToMarkdownString } from "@rspress/core/_private/react";
|
|
3
|
-
import { PageContext, ThemeContext, pathnameToRouteService, removeTrailingSlash, withBase } from "@rspress/runtime";
|
|
3
|
+
import { PageContext, ThemeContext, pathnameToRouteService, removeTrailingSlash, withBase } from "@rspress/core/runtime";
|
|
4
4
|
import { UnheadProvider } from "@unhead/react/server";
|
|
5
5
|
import { StaticRouter } from "react-router-dom";
|
|
6
6
|
import { App } from "./App.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { addLeadingSlash, addTrailingSlash, isProduction, removeTrailingSlash } from '@rspress/shared';
|
|
2
|
+
declare function withBase(url?: string): string;
|
|
3
|
+
declare function removeBase(url: string): string;
|
|
4
|
+
declare function isEqualPath(a: string, b: string): boolean;
|
|
5
|
+
declare function normalizeHrefInRuntime(link: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* we do cleanUrls in runtime side
|
|
8
|
+
*/
|
|
9
|
+
declare function cleanUrlByConfig(link: string): string;
|
|
10
|
+
declare function normalizeImagePath(imagePath: string): string;
|
|
11
|
+
declare function routePathToMdPath(routePath: string): string;
|
|
12
|
+
export { addLeadingSlash, addTrailingSlash, removeTrailingSlash, isProduction, normalizeImagePath, cleanUrlByConfig, removeBase, withBase, isEqualPath, normalizeHrefInRuntime, routePathToMdPath, };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { addLeadingSlash, addTrailingSlash, isDataUrl, isExternalUrl, isProduction, normalizeHref, removeBase, removeHash, removeTrailingSlash, withBase } from "@rspress/shared";
|
|
2
|
+
import virtual_site_data from "virtual-site-data";
|
|
3
|
+
function utils_withBase(url = '/') {
|
|
4
|
+
return withBase(url, virtual_site_data.base);
|
|
5
|
+
}
|
|
6
|
+
function utils_removeBase(url) {
|
|
7
|
+
return removeBase(url, virtual_site_data.base);
|
|
8
|
+
}
|
|
9
|
+
function isEqualPath(a, b) {
|
|
10
|
+
return utils_removeBase(normalizeHref(removeHash(a), true)) === utils_removeBase(normalizeHref(removeHash(b), true));
|
|
11
|
+
}
|
|
12
|
+
function normalizeHrefInRuntime(link) {
|
|
13
|
+
const cleanUrls = Boolean(virtual_site_data?.route?.cleanUrls);
|
|
14
|
+
return normalizeHref(link, cleanUrls);
|
|
15
|
+
}
|
|
16
|
+
function cleanUrlByConfig(link) {
|
|
17
|
+
if (virtual_site_data?.route?.cleanUrls) return normalizeHref(link, true);
|
|
18
|
+
return link;
|
|
19
|
+
}
|
|
20
|
+
function normalizeImagePath(imagePath) {
|
|
21
|
+
if (isAbsoluteUrl(imagePath)) return imagePath;
|
|
22
|
+
if (!imagePath.startsWith('/')) return imagePath;
|
|
23
|
+
return utils_withBase(imagePath);
|
|
24
|
+
}
|
|
25
|
+
function routePathToMdPath(routePath) {
|
|
26
|
+
let url = routePath;
|
|
27
|
+
url = normalizeHref(url, false);
|
|
28
|
+
url = url.replace(/\.html(?=#|\?|$)/, '.md');
|
|
29
|
+
return utils_withBase(url);
|
|
30
|
+
}
|
|
31
|
+
function isAbsoluteUrl(path) {
|
|
32
|
+
return isExternalUrl(path) || isDataUrl(path) || path.startsWith('//');
|
|
33
|
+
}
|
|
34
|
+
export { addLeadingSlash, addTrailingSlash, cleanUrlByConfig, isEqualPath, isProduction, normalizeHrefInRuntime, normalizeImagePath, utils_removeBase as removeBase, removeTrailingSlash, routePathToMdPath, utils_withBase as withBase };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { describe, expect, it, rs } from "@rstest/core";
|
|
2
|
+
import { routePathToMdPath } from "./utils.js";
|
|
3
|
+
rs.mock('virtual-site-data', ()=>({
|
|
4
|
+
default: {
|
|
5
|
+
base: '/'
|
|
6
|
+
}
|
|
7
|
+
}));
|
|
8
|
+
describe('routePathToMdPath', ()=>{
|
|
9
|
+
it('should match snapshot for various paths', ()=>{
|
|
10
|
+
const cases = [
|
|
11
|
+
'/foo/bar.html',
|
|
12
|
+
'/foo/bar.html#hash',
|
|
13
|
+
'/foo/bar.html?q=1',
|
|
14
|
+
'/foo/bar.html?q=1#hash',
|
|
15
|
+
'/foo.html',
|
|
16
|
+
'/simple.html#my-heading',
|
|
17
|
+
'/query.html?foo=bar&baz=qux',
|
|
18
|
+
'/complex.html?id=123#section-2'
|
|
19
|
+
];
|
|
20
|
+
const results = cases.map((path)=>routePathToMdPath(path));
|
|
21
|
+
expect(results).toMatchInlineSnapshot(`
|
|
22
|
+
[
|
|
23
|
+
"/foo/bar.md",
|
|
24
|
+
"/foo/bar.md#hash",
|
|
25
|
+
"/foo/bar.md?q=1",
|
|
26
|
+
"/foo/bar.md?q=1#hash",
|
|
27
|
+
"/foo.md",
|
|
28
|
+
"/simple.md#my-heading",
|
|
29
|
+
"/query.md?foo=bar&baz=qux",
|
|
30
|
+
"/complex.md?id=123#section-2",
|
|
31
|
+
]
|
|
32
|
+
`);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
background-color: var(--rp-container-note-text);
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
.rp-callout--note :not(pre
|
|
102
|
+
.rp-callout--note :not(pre) > code {
|
|
103
103
|
color: var(--rp-container-note-text);
|
|
104
104
|
background-color: var(--rp-container-note-code-bg);
|
|
105
105
|
}
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
background-color: var(--rp-container-tip-text);
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
.rp-callout--tip :not(pre
|
|
124
|
+
.rp-callout--tip :not(pre) > code {
|
|
125
125
|
color: var(--rp-container-tip-text);
|
|
126
126
|
background-color: var(--rp-container-tip-code-bg);
|
|
127
127
|
}
|
|
@@ -143,7 +143,7 @@
|
|
|
143
143
|
background-color: var(--rp-container-info-text);
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
.rp-callout--info :not(pre
|
|
146
|
+
.rp-callout--info :not(pre) > code {
|
|
147
147
|
color: var(--rp-container-info-text);
|
|
148
148
|
background-color: var(--rp-container-info-code-bg);
|
|
149
149
|
}
|
|
@@ -165,7 +165,7 @@
|
|
|
165
165
|
background-color: var(--rp-container-warning-text);
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
.rp-callout--warning :not(pre
|
|
168
|
+
.rp-callout--warning :not(pre) > code {
|
|
169
169
|
color: var(--rp-container-warning-text);
|
|
170
170
|
background-color: var(--rp-container-warning-code-bg);
|
|
171
171
|
}
|
|
@@ -187,7 +187,7 @@
|
|
|
187
187
|
background-color: var(--rp-container-danger-text);
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
-
.rp-callout--caution :not(pre
|
|
190
|
+
.rp-callout--caution :not(pre) > code, .rp-callout--danger :not(pre) > code {
|
|
191
191
|
color: var(--rp-container-danger-text);
|
|
192
192
|
background-color: var(--rp-container-danger-code-bg);
|
|
193
193
|
}
|
|
@@ -209,7 +209,7 @@
|
|
|
209
209
|
background-color: var(--rp-container-details-text);
|
|
210
210
|
}
|
|
211
211
|
|
|
212
|
-
.rp-callout--details :not(pre
|
|
212
|
+
.rp-callout--details :not(pre) > code {
|
|
213
213
|
color: var(--rp-container-details-text);
|
|
214
214
|
background-color: var(--rp-container-details-code-bg);
|
|
215
215
|
}
|
|
@@ -18,7 +18,7 @@ function CodeBlock({ containerElementClassName, title, lang = 'txt', wrapCode: w
|
|
|
18
18
|
className: clsx('rp-codeblock__content', codeWrap && 'rp-codeblock__content--code-wrap', lineNumbersProp && 'rp-codeblock__content--line-numbers'),
|
|
19
19
|
children: [
|
|
20
20
|
/*#__PURE__*/ jsx("div", {
|
|
21
|
-
className: "rp-codeblock__content__scroll-container rp-scrollbar",
|
|
21
|
+
className: "rp-codeblock__content__scroll-container rp-scrollbar rp-scrollbar--always",
|
|
22
22
|
ref: copyElementRef,
|
|
23
23
|
children: children
|
|
24
24
|
}),
|
|
@@ -1,10 +1,30 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useFrontmatter } from "@rspress/core/runtime";
|
|
3
|
+
import { LlmsContainer, LlmsCopyButton, LlmsViewOptions, Tag } from "@theme";
|
|
2
4
|
import clsx from "clsx";
|
|
3
5
|
const H1 = (props)=>{
|
|
4
|
-
const { className, ...rest } = props;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const { className, children, ...rest } = props;
|
|
7
|
+
const { frontmatter: { tag } } = useFrontmatter();
|
|
8
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
9
|
+
children: [
|
|
10
|
+
/*#__PURE__*/ jsxs("h1", {
|
|
11
|
+
className: clsx('rp-toc-include', className),
|
|
12
|
+
...rest,
|
|
13
|
+
children: [
|
|
14
|
+
children,
|
|
15
|
+
" ",
|
|
16
|
+
/*#__PURE__*/ jsx(Tag, {
|
|
17
|
+
tag: tag
|
|
18
|
+
})
|
|
19
|
+
]
|
|
20
|
+
}),
|
|
21
|
+
process.env.ENABLE_LLMS_UI && /*#__PURE__*/ jsxs(LlmsContainer, {
|
|
22
|
+
children: [
|
|
23
|
+
/*#__PURE__*/ jsx(LlmsCopyButton, {}),
|
|
24
|
+
/*#__PURE__*/ jsx(LlmsViewOptions, {})
|
|
25
|
+
]
|
|
26
|
+
})
|
|
27
|
+
]
|
|
8
28
|
});
|
|
9
29
|
};
|
|
10
30
|
const H2 = (props)=>{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { getCustomMDXComponent, renderInlineMarkdown } from "@theme";
|
|
3
3
|
import { slug } from "github-slugger";
|
|
4
4
|
import { useMemo } from "react";
|
|
@@ -14,6 +14,9 @@ const getHeadingMap = ()=>{
|
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
16
|
function FallbackHeading({ level, title }) {
|
|
17
|
+
if (process.env.__SSR_MD__) return /*#__PURE__*/ jsx(Fragment, {
|
|
18
|
+
children: `${'#'.repeat(level)} ${title}\n\n`
|
|
19
|
+
});
|
|
17
20
|
const titleSlug = title && slug(title.trim());
|
|
18
21
|
const Element = useMemo(()=>{
|
|
19
22
|
const headingMap = getHeadingMap();
|
|
@@ -29,7 +29,7 @@ const useNavTransparent = ()=>{
|
|
|
29
29
|
topArrived
|
|
30
30
|
]);
|
|
31
31
|
return /*#__PURE__*/ jsx("style", {
|
|
32
|
-
children: "body:not(.notTopArrived) .rp-nav {background: transparent !important; border-bottom:
|
|
32
|
+
children: "body:not(.notTopArrived) .rp-nav {background: transparent !important; border-bottom: 1px solid transparent !important;}.rp-nav {background: color-mix(in srgb,var(--rp-c-bg) 60%,transparent);backdrop-filter: blur(25px);}"
|
|
33
33
|
});
|
|
34
34
|
};
|
|
35
35
|
export { useNavTransparent };
|
|
@@ -65,6 +65,16 @@
|
|
|
65
65
|
display: flex;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
.rp-home-hero__badge:before {
|
|
69
|
+
content: "";
|
|
70
|
+
background: var(--rp-home-hero-title-bg);
|
|
71
|
+
border-radius: 50%;
|
|
72
|
+
width: 8px;
|
|
73
|
+
height: 8px;
|
|
74
|
+
margin-right: 8px;
|
|
75
|
+
display: inline-block;
|
|
76
|
+
}
|
|
77
|
+
|
|
68
78
|
.rp-home-hero__badge {
|
|
69
79
|
background: var(--rp-c-bg-soft);
|
|
70
80
|
border: 1px solid var(--rp-c-divider-light);
|
|
@@ -74,24 +84,20 @@
|
|
|
74
84
|
padding: .5rem 1rem;
|
|
75
85
|
font-size: .875rem;
|
|
76
86
|
font-weight: 500;
|
|
87
|
+
text-decoration: none;
|
|
88
|
+
transition: background .2s, border-color .2s;
|
|
77
89
|
display: inline-flex;
|
|
78
90
|
}
|
|
79
91
|
|
|
80
|
-
.rp-home-hero__badge:before {
|
|
81
|
-
content: "";
|
|
82
|
-
background: var(--rp-home-hero-title-bg);
|
|
83
|
-
border-radius: 50%;
|
|
84
|
-
width: 8px;
|
|
85
|
-
height: 8px;
|
|
86
|
-
margin-right: 8px;
|
|
87
|
-
display: inline-block;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
92
|
.rp-home-hero__badge:hover {
|
|
91
93
|
background: var(--rp-c-bg-mute);
|
|
92
94
|
cursor: pointer;
|
|
93
95
|
}
|
|
94
96
|
|
|
97
|
+
.rp-home-hero__badge:is(a):hover {
|
|
98
|
+
border-color: var(--rp-c-brand);
|
|
99
|
+
}
|
|
100
|
+
|
|
95
101
|
.rp-home-hero__title {
|
|
96
102
|
font-size: 4rem;
|
|
97
103
|
font-weight: 600;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { normalizeImagePath, useFrontmatter } from "@rspress/core/runtime";
|
|
3
|
-
import { Button, renderHtmlOrText } from "@theme";
|
|
3
|
+
import { Button, Link, renderHtmlOrText } from "@theme";
|
|
4
4
|
import "./index.css";
|
|
5
5
|
import clsx from "clsx";
|
|
6
6
|
const DEFAULT_HERO = {
|
|
@@ -31,10 +31,17 @@ function HomeHero({ beforeHeroActions, afterHeroActions }) {
|
|
|
31
31
|
/*#__PURE__*/ jsxs("div", {
|
|
32
32
|
className: "rp-home-hero__container",
|
|
33
33
|
children: [
|
|
34
|
-
hero.badge && /*#__PURE__*/ jsx("div", {
|
|
34
|
+
hero.badge && ('string' == typeof hero.badge ? /*#__PURE__*/ jsx("div", {
|
|
35
35
|
className: "rp-home-hero__badge",
|
|
36
36
|
children: hero.badge
|
|
37
|
-
}),
|
|
37
|
+
}) : hero.badge.link ? /*#__PURE__*/ jsx(Link, {
|
|
38
|
+
href: hero.badge.link,
|
|
39
|
+
className: "rp-home-hero__badge",
|
|
40
|
+
children: hero.badge.text
|
|
41
|
+
}) : /*#__PURE__*/ jsx("div", {
|
|
42
|
+
className: "rp-home-hero__badge",
|
|
43
|
+
children: hero.badge.text
|
|
44
|
+
})),
|
|
38
45
|
/*#__PURE__*/ jsxs("div", {
|
|
39
46
|
className: "rp-home-hero__content",
|
|
40
47
|
children: [
|