@rspress/core 2.0.13 → 2.0.15
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~execa.js +1 -1
- package/dist/0~rslib-runtime.js +9 -5
- package/dist/3358.js +1 -1
- package/dist/5580.js +2 -2
- package/dist/{2633.js → 6010.js} +12 -9
- package/dist/6646.js +3 -0
- package/dist/8005.js +1 -1
- package/dist/{7275.js → 9958.js} +3 -2
- package/dist/cli/index.js +1 -1
- package/dist/eject-theme/components/Banner/index.scss +11 -0
- package/dist/eject-theme/components/Banner/index.tsx +5 -1
- package/dist/eject-theme/components/DocContent/doc.scss +2 -2
- package/dist/eject-theme/components/HomeBackground/useNavTransparent.tsx +2 -2
- package/dist/eject-theme/components/HoverGroup/index.scss +1 -1
- package/dist/eject-theme/components/LastUpdated/index.tsx +8 -2
- package/dist/eject-theme/components/Link/index.tsx +6 -0
- package/dist/eject-theme/components/Nav/NavMenu.scss +1 -1
- package/dist/eject-theme/components/Nav/hooks.tsx +18 -14
- package/dist/eject-theme/components/Nav/index.tsx +4 -1
- package/dist/eject-theme/components/NavScreen/NavScreenAppearance.tsx +4 -1
- package/dist/eject-theme/components/NavScreen/NavScreenMenuItem.scss +3 -0
- package/dist/eject-theme/components/NavScreen/NavScreenMenuOthers.tsx +4 -1
- package/dist/eject-theme/components/Outline/index.tsx +0 -6
- package/dist/eject-theme/components/Search/SearchPanel.tsx +24 -17
- package/dist/eject-theme/components/Search/logic/search.ts +15 -16
- package/dist/eject-theme/components/SidebarMenu/index.tsx +10 -3
- package/dist/eject-theme/components/SidebarMenu/useSidebarMenu.tsx +12 -3
- package/dist/eject-theme/components/SocialLinks/GithubStars.tsx +120 -0
- package/dist/eject-theme/components/SocialLinks/SocialLink.tsx +5 -0
- package/dist/eject-theme/components/SocialLinks/index.scss +17 -0
- package/dist/eject-theme/components/Tag/index.test.tsx +55 -0
- package/dist/eject-theme/components/Tag/index.tsx +19 -5
- package/dist/index.d.ts +1 -1
- package/dist/node/PluginDriver.js +4 -4
- package/dist/node/auto-nav-sidebar/index.js +1 -1
- package/dist/node/auto-nav-sidebar/locales.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.d.ts +4 -2
- package/dist/node/auto-nav-sidebar/walk.js +3 -3
- package/dist/node/constants.d.ts +2 -1
- package/dist/node/constants.js +12 -6
- package/dist/node/initRsbuild.js +21 -19
- package/dist/node/last-updated/index.d.ts +3 -3
- package/dist/node/last-updated/index.js +24 -9
- package/dist/node/mdx/options.js +8 -1
- package/dist/node/mdx/processor.js +3 -1
- package/dist/node/mdx/rehypePlugins/headerAnchor.d.ts +1 -1
- package/dist/node/mdx/rehypePlugins/headerAnchor.js +10 -6
- package/dist/node/mdx/remarkPlugins/link.js +91 -16
- package/dist/node/mdx/remarkPlugins/toc.d.ts +8 -1
- package/dist/node/mdx/remarkPlugins/toc.js +44 -15
- package/dist/node/route/RoutePage.js +1 -1
- package/dist/node/route/RouteService.d.ts +6 -0
- package/dist/node/route/RouteService.js +41 -7
- package/dist/node/route/extractPageData.js +1 -1
- package/dist/node/route/normalizeRoutePath.js +1 -1
- package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.d.ts +7 -0
- package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.js +7 -0
- package/dist/node/runtimeModule/i18n.js +1 -1
- package/dist/node/runtimeModule/pageData/createPageData.js +2 -1
- package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
- package/dist/node/runtimeModule/searchHooks.js +1 -1
- package/dist/node/runtimeModule/siteData/createSiteData.js +1 -1
- package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +12 -2
- package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +33 -9
- package/dist/node/serve.js +1 -1
- package/dist/node/ssg/htmlFile.d.ts +2 -0
- package/dist/node/ssg/htmlFile.js +14 -0
- package/dist/node/ssg/renderPage.js +1 -1
- package/dist/node/ssg/renderPageWorker.d.ts +3 -6
- package/dist/node/ssg/renderPageWorker.js +24 -4
- package/dist/node/ssg/renderPages.d.ts +1 -1
- package/dist/node/ssg/renderPages.js +18 -17
- package/dist/node/ssg/rsbuildPluginCSR.js +2 -1
- package/dist/node/ssg/rsbuildPluginSSG.js +6 -4
- package/dist/node/ssg/ssgEnv.js +1 -1
- package/dist/node/ssg-md/llms/emitLlmsTxt.js +1 -1
- package/dist/node/ssg-md/llms/llmsTxt.js +1 -1
- package/dist/node/ssg-md/renderPage.js +1 -1
- package/dist/node/ssg-md/renderPages.js +2 -2
- package/dist/node/ssg-md/rsbuildPluginSSGMD.js +3 -2
- package/dist/node/utils/checkLanguageParity.js +1 -1
- package/dist/node/utils/createHash.js +1 -1
- package/dist/node/utils/flattenMdxContent.js +1 -1
- package/dist/node/utils/getPageKey.js +1 -1
- package/dist/node/utils/reactAlias.js +1 -1
- package/dist/runtime/App.d.ts +2 -1
- package/dist/runtime/ClientApp.d.ts +1 -1
- package/dist/runtime/Content.d.ts +1 -1
- package/dist/runtime/NoSSR.d.ts +1 -1
- package/dist/theme/components/Badge/index.d.ts +1 -1
- package/dist/theme/components/Banner/index.css +11 -0
- package/dist/theme/components/Banner/index.js +1 -0
- package/dist/theme/components/CodeBlock/index.d.ts +1 -1
- package/dist/theme/components/CodeButtonGroup/CopyCodeButton.d.ts +1 -1
- package/dist/theme/components/CodeButtonGroup/index.d.ts +1 -1
- package/dist/theme/components/DocContent/doc.css +2 -2
- package/dist/theme/components/DocContent/docComponents/a.d.ts +1 -1
- package/dist/theme/components/DocContent/docComponents/code.d.ts +1 -1
- package/dist/theme/components/DocContent/docComponents/hr.d.ts +1 -1
- package/dist/theme/components/DocContent/docComponents/img.d.ts +1 -1
- package/dist/theme/components/DocContent/docComponents/index.d.ts +18 -18
- package/dist/theme/components/DocContent/docComponents/list.d.ts +3 -3
- package/dist/theme/components/DocContent/docComponents/paragraph.d.ts +3 -3
- package/dist/theme/components/DocContent/docComponents/pre.d.ts +1 -1
- package/dist/theme/components/DocContent/docComponents/table.d.ts +3 -3
- package/dist/theme/components/DocContent/docComponents/title.d.ts +6 -6
- package/dist/theme/components/DocContent/index.d.ts +1 -1
- package/dist/theme/components/DocFooter/index.d.ts +1 -1
- package/dist/theme/components/EditLink/index.d.ts +1 -1
- package/dist/theme/components/FallbackHeading/index.d.ts +1 -1
- package/dist/theme/components/HomeBackground/index.d.ts +1 -1
- package/dist/theme/components/HomeBackground/useNavTransparent.d.ts +1 -1
- package/dist/theme/components/HomeBackground/useNavTransparent.js +2 -2
- package/dist/theme/components/HomeFeature/useCardAnimation.d.ts +1 -1
- package/dist/theme/components/HomeFooter/index.d.ts +1 -1
- package/dist/theme/components/HomeHero/index.d.ts +1 -1
- package/dist/theme/components/HoverGroup/index.css +1 -1
- package/dist/theme/components/HoverGroup/index.d.ts +1 -1
- 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 +13 -3
- package/dist/theme/components/Link/index.js +6 -0
- package/dist/theme/components/Llms/LlmsContainer.d.ts +1 -1
- package/dist/theme/components/Llms/LlmsCopyButton.d.ts +1 -1
- package/dist/theme/components/Llms/LlmsCopyRow.d.ts +1 -1
- package/dist/theme/components/Llms/LlmsOpenRow.d.ts +1 -1
- package/dist/theme/components/Llms/LlmsViewOptions.d.ts +1 -1
- package/dist/theme/components/Nav/NavMenu.css +1 -1
- package/dist/theme/components/Nav/NavMenu.d.ts +9 -9
- package/dist/theme/components/Nav/hooks.js +6 -3
- package/dist/theme/components/Nav/index.d.ts +1 -1
- package/dist/theme/components/Nav/index.js +2 -1
- package/dist/theme/components/NavHamburger/index.d.ts +1 -1
- package/dist/theme/components/NavScreen/NavScreenAppearance.d.ts +1 -1
- package/dist/theme/components/NavScreen/NavScreenAppearance.js +2 -1
- package/dist/theme/components/NavScreen/NavScreenLangs.d.ts +1 -1
- package/dist/theme/components/NavScreen/NavScreenMenu.d.ts +1 -1
- package/dist/theme/components/NavScreen/NavScreenMenuItem.css +10 -1
- package/dist/theme/components/NavScreen/NavScreenMenuItem.d.ts +5 -5
- package/dist/theme/components/NavScreen/NavScreenMenuOthers.d.ts +1 -1
- package/dist/theme/components/NavScreen/NavScreenMenuOthers.js +2 -1
- package/dist/theme/components/NavScreen/NavScreenVersions.d.ts +1 -1
- package/dist/theme/components/NavScreen/index.d.ts +2 -2
- package/dist/theme/components/NavTitle/index.d.ts +1 -1
- package/dist/theme/components/Outline/ScrollToTop.d.ts +1 -1
- package/dist/theme/components/Outline/index.d.ts +1 -1
- package/dist/theme/components/Outline/index.js +1 -3
- package/dist/theme/components/Overview/index.d.ts +1 -1
- package/dist/theme/components/OverviewGroup/index.d.ts +1 -1
- package/dist/theme/components/PackageManagerTabs/icons/Bun.d.ts +1 -1
- package/dist/theme/components/PackageManagerTabs/icons/Deno.d.ts +1 -1
- package/dist/theme/components/PackageManagerTabs/icons/Npm.d.ts +1 -1
- package/dist/theme/components/PackageManagerTabs/icons/Pnpm.d.ts +1 -1
- package/dist/theme/components/PackageManagerTabs/icons/Yarn.d.ts +1 -1
- package/dist/theme/components/PackageManagerTabs/index.d.ts +1 -1
- package/dist/theme/components/PrevNextPage/index.d.ts +1 -1
- package/dist/theme/components/Prompt/index.d.ts +1 -1
- package/dist/theme/components/ReadPercent/index.d.ts +1 -1
- package/dist/theme/components/Root/index.d.ts +1 -1
- package/dist/theme/components/Search/NoSearchResult.d.ts +1 -1
- package/dist/theme/components/Search/SearchButton.d.ts +1 -1
- package/dist/theme/components/Search/SearchPanel.d.ts +1 -1
- package/dist/theme/components/Search/SearchPanel.js +12 -7
- package/dist/theme/components/Search/SuggestItem.d.ts +1 -1
- package/dist/theme/components/Search/index.d.ts +1 -1
- package/dist/theme/components/Search/logic/search.js +12 -7
- package/dist/theme/components/Sidebar/SidebarDivider.d.ts +1 -1
- package/dist/theme/components/Sidebar/SidebarGroup.d.ts +1 -1
- package/dist/theme/components/Sidebar/SidebarItem.d.ts +2 -2
- package/dist/theme/components/Sidebar/SidebarSectionHeader.d.ts +1 -1
- package/dist/theme/components/Sidebar/index.d.ts +2 -2
- package/dist/theme/components/SidebarMenu/index.d.ts +3 -0
- package/dist/theme/components/SidebarMenu/index.js +4 -3
- package/dist/theme/components/SidebarMenu/useSidebarMenu.d.ts +3 -2
- package/dist/theme/components/SidebarMenu/useSidebarMenu.js +7 -3
- package/dist/theme/components/SocialLinks/GithubStars.d.ts +7 -0
- package/dist/theme/components/SocialLinks/GithubStars.js +85 -0
- package/dist/theme/components/SocialLinks/SocialLink.d.ts +1 -1
- package/dist/theme/components/SocialLinks/SocialLink.js +5 -0
- package/dist/theme/components/SocialLinks/index.css +19 -0
- package/dist/theme/components/SocialLinks/index.d.ts +1 -1
- package/dist/theme/components/SourceCode/index.d.ts +1 -1
- package/dist/theme/components/Steps/index.d.ts +1 -1
- package/dist/theme/components/SvgWrapper/index.d.ts +1 -1
- package/dist/theme/components/SwitchAppearance/index.d.ts +1 -1
- package/dist/theme/components/Tag/index.d.ts +1 -1
- package/dist/theme/components/Tag/index.js +9 -5
- package/dist/theme/components/Toc/TocItem.d.ts +1 -1
- package/dist/theme/components/Toc/index.d.ts +1 -1
- package/dist/theme/layout/DocLayout/index.d.ts +1 -1
- package/dist/theme/layout/DocLayout/index.js +1 -1
- package/dist/theme/layout/HomeLayout/index.d.ts +1 -1
- package/dist/theme/layout/Layout/index.d.ts +1 -1
- package/dist/theme/layout/NotFountLayout/index.d.ts +1 -1
- package/dist/theme/logic/useThemeState.d.ts +6 -7
- package/dist/theme/logic/useThemeState.js +19 -15
- package/package.json +20 -21
- package/dist/559.js +0 -1
|
@@ -4,12 +4,13 @@ import { IconArrowRight, IconMenu, ReadPercent, SvgWrapper, renderInlineMarkdown
|
|
|
4
4
|
import { forwardRef, useEffect, useRef } from "react";
|
|
5
5
|
import { createPortal } from "react-dom";
|
|
6
6
|
import "./index.css";
|
|
7
|
-
const SidebarMenu = /*#__PURE__*/ forwardRef(({ isSidebarOpen, onIsSidebarOpenChange, isOutlineOpen, onIsOutlineOpenChange }, forwardedRef)=>{
|
|
7
|
+
const SidebarMenu = /*#__PURE__*/ forwardRef(({ isSidebarOpen, onIsSidebarOpenChange, isOutlineOpen, onIsOutlineOpenChange, beforeOutline, afterOutline }, forwardedRef)=>{
|
|
8
8
|
const sidebarMenuRef = useRef(null);
|
|
9
9
|
const t = useI18n();
|
|
10
10
|
const { pathname, hash } = useLocation();
|
|
11
11
|
const headers = useDynamicToc();
|
|
12
12
|
const { scrolledHeader } = useActiveAnchor(headers);
|
|
13
|
+
const outlineDisabled = !beforeOutline && !afterOutline && 0 === headers.length;
|
|
13
14
|
const { frontmatter: { sidebar: sidebarConfig = true, outline: showOutline = true } } = useFrontmatter();
|
|
14
15
|
const showSidebar = true === sidebarConfig;
|
|
15
16
|
function openSidebar() {
|
|
@@ -61,7 +62,7 @@ const SidebarMenu = /*#__PURE__*/ forwardRef(({ isSidebarOpen, onIsSidebarOpenCh
|
|
|
61
62
|
}),
|
|
62
63
|
showOutline ? /*#__PURE__*/ jsxs("button", {
|
|
63
64
|
type: "button",
|
|
64
|
-
disabled:
|
|
65
|
+
disabled: outlineDisabled,
|
|
65
66
|
onClick: (e)=>{
|
|
66
67
|
e.preventDefault();
|
|
67
68
|
e.stopPropagation();
|
|
@@ -80,7 +81,7 @@ const SidebarMenu = /*#__PURE__*/ forwardRef(({ isSidebarOpen, onIsSidebarOpenCh
|
|
|
80
81
|
size: 14,
|
|
81
82
|
strokeWidth: 2
|
|
82
83
|
}),
|
|
83
|
-
|
|
84
|
+
!outlineDisabled && /*#__PURE__*/ jsx(SvgWrapper, {
|
|
84
85
|
icon: IconArrowRight,
|
|
85
86
|
className: "rp-sidebar-menu__right__icon",
|
|
86
87
|
style: {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
declare function useSidebarMenu(beforeOutline?: ReactNode, afterOutline?: ReactNode): {
|
|
3
|
+
sidebarMenu: import("react").JSX.Element;
|
|
3
4
|
isOutlineOpen: boolean;
|
|
4
5
|
isSidebarOpen: boolean;
|
|
5
6
|
sidebarLayoutRef: import("react").RefObject<HTMLDivElement | null>;
|
|
@@ -3,7 +3,7 @@ import { clearAllBodyScrollLocks, disableBodyScroll } from "body-scroll-lock";
|
|
|
3
3
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
4
4
|
import { SidebarMenu } from "./index.js";
|
|
5
5
|
import { useClickOutside } from "./useClickOutside.js";
|
|
6
|
-
function useSidebarMenu() {
|
|
6
|
+
function useSidebarMenu(beforeOutline, afterOutline) {
|
|
7
7
|
const [isSidebarOpen, setIsSidebarOpen] = useState(false);
|
|
8
8
|
const [isOutlineOpen, setIsOutlineOpen] = useState(false);
|
|
9
9
|
const sidebarMenuRef = useRef(null);
|
|
@@ -37,12 +37,16 @@ function useSidebarMenu() {
|
|
|
37
37
|
onIsSidebarOpenChange: setIsSidebarOpen,
|
|
38
38
|
isOutlineOpen: isOutlineOpen,
|
|
39
39
|
onIsOutlineOpenChange: setIsOutlineOpen,
|
|
40
|
-
ref: sidebarMenuRef
|
|
40
|
+
ref: sidebarMenuRef,
|
|
41
|
+
beforeOutline: beforeOutline,
|
|
42
|
+
afterOutline: afterOutline
|
|
41
43
|
}), [
|
|
42
44
|
isOutlineOpen,
|
|
43
45
|
isSidebarOpen,
|
|
44
46
|
setIsOutlineOpen,
|
|
45
|
-
setIsSidebarOpen
|
|
47
|
+
setIsSidebarOpen,
|
|
48
|
+
beforeOutline,
|
|
49
|
+
afterOutline
|
|
46
50
|
]);
|
|
47
51
|
return {
|
|
48
52
|
sidebarMenu,
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
const TTL_MS = 3600000;
|
|
4
|
+
function storageKey(repo) {
|
|
5
|
+
return `rp-github-stars:${repo}`;
|
|
6
|
+
}
|
|
7
|
+
function parseRepo(content) {
|
|
8
|
+
try {
|
|
9
|
+
const url = new URL(content);
|
|
10
|
+
const host = url.hostname.replace(/^www\./, '');
|
|
11
|
+
if ('github.com' !== host) return null;
|
|
12
|
+
const match = url.pathname.match(/^\/([^/]+)\/([^/]+)/);
|
|
13
|
+
if (!match) return null;
|
|
14
|
+
return `${match[1]}/${match[2].replace(/\.git$/, '')}`;
|
|
15
|
+
} catch {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function readCache(repo) {
|
|
20
|
+
if ("u" < typeof localStorage) return null;
|
|
21
|
+
try {
|
|
22
|
+
const raw = localStorage.getItem(storageKey(repo));
|
|
23
|
+
if (!raw) return null;
|
|
24
|
+
const parsed = JSON.parse(raw);
|
|
25
|
+
if ('number' != typeof parsed?.count || 'number' != typeof parsed?.fetchedAt) return null;
|
|
26
|
+
return parsed;
|
|
27
|
+
} catch {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function writeCache(repo, count) {
|
|
32
|
+
if ("u" < typeof localStorage) return;
|
|
33
|
+
try {
|
|
34
|
+
localStorage.setItem(storageKey(repo), JSON.stringify({
|
|
35
|
+
count,
|
|
36
|
+
fetchedAt: Date.now()
|
|
37
|
+
}));
|
|
38
|
+
} catch {}
|
|
39
|
+
}
|
|
40
|
+
function formatCount(count) {
|
|
41
|
+
if (count >= 1000000) return `${(count / 1000000).toFixed(1)}M`;
|
|
42
|
+
if (count >= 1000) return `${(count / 1000).toFixed(1)}K`;
|
|
43
|
+
return String(count);
|
|
44
|
+
}
|
|
45
|
+
const GithubStars = (props)=>{
|
|
46
|
+
const { content, icon } = props;
|
|
47
|
+
const repo = parseRepo(content);
|
|
48
|
+
const [count, setCount] = useState(()=>repo ? readCache(repo)?.count ?? null : null);
|
|
49
|
+
useEffect(()=>{
|
|
50
|
+
if (!repo) return;
|
|
51
|
+
const cached = readCache(repo);
|
|
52
|
+
if (cached && Date.now() - cached.fetchedAt < TTL_MS) return;
|
|
53
|
+
let cancelled = false;
|
|
54
|
+
fetch(`https://api.github.com/repos/${repo}`).then((res)=>res.ok ? res.json() : Promise.reject(res.status)).then((data)=>{
|
|
55
|
+
if (cancelled) return;
|
|
56
|
+
if ('number' == typeof data?.stargazers_count) {
|
|
57
|
+
setCount(data.stargazers_count);
|
|
58
|
+
writeCache(repo, data.stargazers_count);
|
|
59
|
+
}
|
|
60
|
+
}).catch(()=>{});
|
|
61
|
+
return ()=>{
|
|
62
|
+
cancelled = true;
|
|
63
|
+
};
|
|
64
|
+
}, [
|
|
65
|
+
repo
|
|
66
|
+
]);
|
|
67
|
+
return /*#__PURE__*/ jsxs("a", {
|
|
68
|
+
href: content,
|
|
69
|
+
target: "_blank",
|
|
70
|
+
rel: "noopener noreferrer",
|
|
71
|
+
className: "rp-social-links__item rp-social-links__github-stars",
|
|
72
|
+
"aria-label": null == count ? 'GitHub repository' : `GitHub repository, ${count.toLocaleString()} stars`,
|
|
73
|
+
children: [
|
|
74
|
+
/*#__PURE__*/ jsx("div", {
|
|
75
|
+
className: "rp-social-links__icon",
|
|
76
|
+
children: icon
|
|
77
|
+
}),
|
|
78
|
+
null != count && /*#__PURE__*/ jsx("span", {
|
|
79
|
+
className: "rp-social-links__github-stars-count",
|
|
80
|
+
children: formatCount(count)
|
|
81
|
+
})
|
|
82
|
+
]
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
export { GithubStars };
|
|
@@ -7,5 +7,5 @@ interface SocialLinkProps {
|
|
|
7
7
|
*/
|
|
8
8
|
hoverGroupPosition?: 'center' | 'left' | 'right';
|
|
9
9
|
}
|
|
10
|
-
export declare const SocialLink: (props: SocialLinkProps) => import("react
|
|
10
|
+
export declare const SocialLink: (props: SocialLinkProps) => import("react").JSX.Element;
|
|
11
11
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import virtual_social_links from "virtual-social-links";
|
|
3
3
|
import "./index.css";
|
|
4
|
+
import { GithubStars } from "./GithubStars.js";
|
|
4
5
|
import { useHoverGroup } from "../HoverGroup/useHoverGroup.js";
|
|
5
6
|
const SocialLink = (props)=>{
|
|
6
7
|
const { link, hoverGroupPosition = 'center' } = props;
|
|
@@ -42,6 +43,10 @@ const SocialLink = (props)=>{
|
|
|
42
43
|
children: IconComp
|
|
43
44
|
})
|
|
44
45
|
}, content);
|
|
46
|
+
if ('github-stars' === mode) return /*#__PURE__*/ jsx(GithubStars, {
|
|
47
|
+
content: content,
|
|
48
|
+
icon: IconComp
|
|
49
|
+
});
|
|
45
50
|
if ('text' === mode) return /*#__PURE__*/ jsxs("div", {
|
|
46
51
|
className: "rp-social-links__item",
|
|
47
52
|
onMouseEnter: handleMouseEnter,
|
|
@@ -42,3 +42,22 @@
|
|
|
42
42
|
display: flex;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
.rp-social-links__github-stars {
|
|
46
|
+
color: var(--rp-c-text-2);
|
|
47
|
+
flex-direction: row;
|
|
48
|
+
gap: 6px;
|
|
49
|
+
text-decoration: none;
|
|
50
|
+
transition: color .2s;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.rp-social-links__github-stars:hover {
|
|
54
|
+
color: var(--rp-c-text-1);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.rp-social-links__github-stars-count {
|
|
58
|
+
font-variant-numeric: tabular-nums;
|
|
59
|
+
font-size: 13px;
|
|
60
|
+
font-weight: 500;
|
|
61
|
+
line-height: 1;
|
|
62
|
+
}
|
|
63
|
+
|
|
@@ -3,4 +3,4 @@ export interface SourceCodeProps {
|
|
|
3
3
|
href: string;
|
|
4
4
|
platform?: 'github' | 'gitlab';
|
|
5
5
|
}
|
|
6
|
-
export declare function SourceCode(props: SourceCodeProps): import("react
|
|
6
|
+
export declare function SourceCode(props: SourceCodeProps): import("react").JSX.Element;
|
|
@@ -10,4 +10,4 @@ export type SvgWrapperProps = {
|
|
|
10
10
|
* - Other strings (emoji/text/HTML): render with renderHtmlOrText
|
|
11
11
|
* @internal
|
|
12
12
|
*/
|
|
13
|
-
export declare function SvgWrapper({ icon: Icon, ...rest }: SvgWrapperProps): import("react
|
|
13
|
+
export declare function SvgWrapper({ icon: Icon, ...rest }: SvgWrapperProps): import("react").JSX.Element | null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { isDataUrl, isExternalUrl } from "@rspress/core/runtime";
|
|
2
|
+
import { isDataUrl, isExternalUrl, normalizeImagePath } from "@rspress/core/runtime";
|
|
3
3
|
import { Badge, IconDeprecated, IconExperimental, SvgWrapper, Tag } from "@rspress/core/theme";
|
|
4
4
|
import { useMemo } from "react";
|
|
5
5
|
const BADGE_TAGS = {
|
|
@@ -8,15 +8,19 @@ const BADGE_TAGS = {
|
|
|
8
8
|
warning: 'warning',
|
|
9
9
|
danger: 'danger'
|
|
10
10
|
};
|
|
11
|
+
const IMAGE_EXT_REGEXP = /\.(?:avif|gif|ico|jpe?g|png|svg|webp)(?:[?#].*)?$/i;
|
|
11
12
|
function parseCommonTagsArrayStr(tagStr) {
|
|
12
13
|
const tags = tagStr.split(',').map((tag)=>tag.trim()).filter((tag)=>tag.length > 0);
|
|
13
14
|
return tags;
|
|
14
15
|
}
|
|
16
|
+
function isPublicFolderPath(tag) {
|
|
17
|
+
return tag.startsWith('/');
|
|
18
|
+
}
|
|
15
19
|
const getTagType = (tag)=>{
|
|
16
20
|
const normalizedTag = tag.trim();
|
|
17
21
|
const isSvgTagString = normalizedTag.startsWith('<svg');
|
|
18
|
-
const isPic = isExternalUrl(normalizedTag) || isDataUrl(normalizedTag);
|
|
19
|
-
const tagsArray = parseCommonTagsArrayStr(normalizedTag);
|
|
22
|
+
const isPic = isExternalUrl(normalizedTag) || isDataUrl(normalizedTag) || isPublicFolderPath(normalizedTag) && IMAGE_EXT_REGEXP.test(normalizedTag);
|
|
23
|
+
const tagsArray = isSvgTagString || isPic ? null : parseCommonTagsArrayStr(normalizedTag);
|
|
20
24
|
return {
|
|
21
25
|
isSvgTagString,
|
|
22
26
|
isPic,
|
|
@@ -37,7 +41,7 @@ const Tag_Tag = ({ tag })=>{
|
|
|
37
41
|
});
|
|
38
42
|
if (isSvgTagString) return /*#__PURE__*/ jsx("div", {
|
|
39
43
|
dangerouslySetInnerHTML: {
|
|
40
|
-
__html:
|
|
44
|
+
__html: normalizedTag
|
|
41
45
|
},
|
|
42
46
|
style: {
|
|
43
47
|
width: 20,
|
|
@@ -45,7 +49,7 @@ const Tag_Tag = ({ tag })=>{
|
|
|
45
49
|
}
|
|
46
50
|
});
|
|
47
51
|
if (isPic) return /*#__PURE__*/ jsx("img", {
|
|
48
|
-
src:
|
|
52
|
+
src: normalizeImagePath(normalizedTag)
|
|
49
53
|
});
|
|
50
54
|
if ('experimental' === normalizedTag) return /*#__PURE__*/ jsxs(Badge, {
|
|
51
55
|
type: "warning",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function Toc(): import("react
|
|
1
|
+
export declare function Toc(): import("react").JSX.Element;
|
|
@@ -13,4 +13,4 @@ export interface DocLayoutProps {
|
|
|
13
13
|
navTitle?: React.ReactNode;
|
|
14
14
|
components?: Record<string, React.FC>;
|
|
15
15
|
}
|
|
16
|
-
export declare function DocLayout(props: DocLayoutProps): import("react
|
|
16
|
+
export declare function DocLayout(props: DocLayoutProps): import("react").JSX.Element;
|
|
@@ -25,7 +25,7 @@ function DocLayout(props) {
|
|
|
25
25
|
})
|
|
26
26
|
});
|
|
27
27
|
const isDocWide = 'doc-wide' === pageType;
|
|
28
|
-
const { isOutlineOpen, isSidebarOpen, sidebarMenu, asideLayoutRef, sidebarLayoutRef } = useSidebarMenu();
|
|
28
|
+
const { isOutlineOpen, isSidebarOpen, sidebarMenu, asideLayoutRef, sidebarLayoutRef } = useSidebarMenu(beforeOutline, afterOutline);
|
|
29
29
|
const { rspressDocRef } = useWatchToc();
|
|
30
30
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
31
31
|
children: [
|
|
@@ -6,4 +6,4 @@ export interface HomeLayoutProps {
|
|
|
6
6
|
beforeFeatures?: React.ReactNode;
|
|
7
7
|
afterFeatures?: React.ReactNode;
|
|
8
8
|
}
|
|
9
|
-
export declare function HomeLayout(props: HomeLayoutProps): import("react
|
|
9
|
+
export declare function HomeLayout(props: HomeLayoutProps): import("react").JSX.Element;
|
|
@@ -9,4 +9,4 @@ export type LayoutProps = {
|
|
|
9
9
|
beforeNav?: React.ReactNode;
|
|
10
10
|
afterNav?: React.ReactNode;
|
|
11
11
|
} & Omit<DocLayoutProps, 'uiSwitch'> & HomeLayoutProps & NavProps;
|
|
12
|
-
export declare function Layout(props: LayoutProps):
|
|
12
|
+
export declare function Layout(props: LayoutProps): React.JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import './index.scss';
|
|
2
|
-
export declare function NotFoundLayout(): import("react
|
|
2
|
+
export declare function NotFoundLayout(): import("react").JSX.Element | null;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
export type ThemeValue = 'light' | 'dark';
|
|
3
|
-
/** Theme config value stored in localStorage */
|
|
4
|
-
export type ThemeConfigValue = ThemeValue | 'auto';
|
|
5
|
-
export declare const getStoredThemeConfig: (theme: ThemeValue, prefersDark: boolean) => ThemeConfigValue;
|
|
6
|
-
export declare const getResolvedTheme: (config: ThemeConfigValue, prefersDark: boolean) => ThemeValue;
|
|
1
|
+
type ThemeValue = 'dark' | 'light';
|
|
7
2
|
/**
|
|
8
3
|
* State provider for theme context.
|
|
9
4
|
* @internal
|
|
10
5
|
*/
|
|
11
|
-
export declare function useThemeState(): readonly [
|
|
6
|
+
export declare function useThemeState(): readonly [
|
|
7
|
+
ThemeValue,
|
|
8
|
+
(value: ThemeValue) => void
|
|
9
|
+
];
|
|
10
|
+
export {};
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import { useSite } from "@rspress/core/runtime";
|
|
2
|
+
import { getDefaultDarkModeValue, isDarkModeSwitchEnabled } from "@rspress/shared";
|
|
2
3
|
import { useCallback, useLayoutEffect } from "react";
|
|
3
4
|
import { useMediaQuery } from "./useMediaQuery.js";
|
|
4
5
|
import { useStorageValue } from "./useStorageValue.js";
|
|
5
6
|
const APPEARANCE_KEY = 'rspress-theme-appearance';
|
|
6
7
|
const MEDIA_QUERY = '(prefers-color-scheme: dark)';
|
|
7
|
-
const getSystemTheme = (prefersDark)=>prefersDark ? 'dark' : 'light';
|
|
8
|
-
const getStoredThemeConfig = (theme, prefersDark)=>{
|
|
9
|
-
const systemTheme = getSystemTheme(prefersDark);
|
|
10
|
-
return theme === systemTheme ? 'auto' : theme;
|
|
11
|
-
};
|
|
12
|
-
const getResolvedTheme = (config, prefersDark)=>'auto' === config ? getSystemTheme(prefersDark) : config;
|
|
13
8
|
const applyThemeToDOM = (theme)=>{
|
|
14
9
|
if (!document?.documentElement) return;
|
|
15
10
|
const root = document.documentElement;
|
|
@@ -17,19 +12,28 @@ const applyThemeToDOM = (theme)=>{
|
|
|
17
12
|
root.classList.toggle('rp-dark', 'dark' === theme);
|
|
18
13
|
root.style.colorScheme = theme;
|
|
19
14
|
};
|
|
15
|
+
function useSystemTheme() {
|
|
16
|
+
const prefersDark = useMediaQuery(MEDIA_QUERY);
|
|
17
|
+
const system = prefersDark ? 'dark' : 'light';
|
|
18
|
+
return system;
|
|
19
|
+
}
|
|
20
20
|
function useThemeState() {
|
|
21
21
|
const { site } = useSite();
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
22
|
+
const { darkMode } = site.themeConfig;
|
|
23
|
+
const canSwitchDarkMode = isDarkModeSwitchEnabled(darkMode);
|
|
24
|
+
const defaultThemeConfig = getDefaultDarkModeValue(darkMode);
|
|
25
|
+
const [storedConfig, setStoredConfig] = useStorageValue(APPEARANCE_KEY, defaultThemeConfig);
|
|
26
|
+
const validatedStoredConfig = 'light' === storedConfig || 'dark' === storedConfig || 'auto' === storedConfig ? storedConfig : null;
|
|
27
|
+
const system = useSystemTheme();
|
|
28
|
+
const themeConfigValue = canSwitchDarkMode ? validatedStoredConfig ?? defaultThemeConfig : defaultThemeConfig;
|
|
29
|
+
const theme = 'auto' === themeConfigValue ? system : themeConfigValue;
|
|
26
30
|
const setTheme = useCallback((value)=>{
|
|
27
|
-
if (
|
|
28
|
-
setStoredConfig(
|
|
31
|
+
if (!canSwitchDarkMode) return;
|
|
32
|
+
setStoredConfig(system === value ? 'auto' : value);
|
|
29
33
|
applyThemeToDOM(value);
|
|
30
34
|
}, [
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
canSwitchDarkMode,
|
|
36
|
+
system,
|
|
33
37
|
setStoredConfig
|
|
34
38
|
]);
|
|
35
39
|
useLayoutEffect(()=>{
|
|
@@ -42,4 +46,4 @@ function useThemeState() {
|
|
|
42
46
|
setTheme
|
|
43
47
|
];
|
|
44
48
|
}
|
|
45
|
-
export {
|
|
49
|
+
export { useThemeState };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspress/core",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.15",
|
|
4
4
|
"description": "The Rspress Documentation Framework",
|
|
5
5
|
"bugs": "https://github.com/web-infra-dev/rspress/issues",
|
|
6
6
|
"repository": {
|
|
@@ -60,9 +60,9 @@
|
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@mdx-js/mdx": "^3.1.1",
|
|
62
62
|
"@mdx-js/react": "^3.1.1",
|
|
63
|
-
"@rsbuild/core": "^2.0.
|
|
64
|
-
"@rsbuild/plugin-react": "~2.0.
|
|
65
|
-
"@shikijs/rehype": "^4.0
|
|
63
|
+
"@rsbuild/core": "^2.0.15",
|
|
64
|
+
"@rsbuild/plugin-react": "~2.0.1",
|
|
65
|
+
"@shikijs/rehype": "^4.2.0",
|
|
66
66
|
"@types/unist": "^3.0.3",
|
|
67
67
|
"@unhead/react": "^2.1.15",
|
|
68
68
|
"body-scroll-lock": "4.0.0-beta.0",
|
|
@@ -75,56 +75,55 @@
|
|
|
75
75
|
"mdast-util-mdxjs-esm": "^2.0.1",
|
|
76
76
|
"medium-zoom": "1.1.0",
|
|
77
77
|
"nprogress": "^0.2.0",
|
|
78
|
-
"react": "^19.2.
|
|
79
|
-
"react-dom": "^19.2.
|
|
78
|
+
"react": "^19.2.7",
|
|
79
|
+
"react-dom": "^19.2.7",
|
|
80
80
|
"react-lazy-with-preload": "^2.2.1",
|
|
81
81
|
"react-reconciler": "0.33.0",
|
|
82
82
|
"react-render-to-markdown": "19.1.0",
|
|
83
83
|
"react-router-dom": "^7.15.1",
|
|
84
84
|
"rehype-external-links": "^3.0.0",
|
|
85
85
|
"rehype-raw": "^7.0.0",
|
|
86
|
-
"remark-cjk-friendly": "^2.
|
|
87
|
-
"remark-cjk-friendly-gfm-strikethrough": "^2.0
|
|
86
|
+
"remark-cjk-friendly": "^2.3.1",
|
|
87
|
+
"remark-cjk-friendly-gfm-strikethrough": "^2.1.0",
|
|
88
88
|
"remark-gfm": "^4.0.1",
|
|
89
89
|
"remark-mdx": "^3.1.1",
|
|
90
90
|
"remark-parse": "^11.0.0",
|
|
91
91
|
"remark-stringify": "^11.0.0",
|
|
92
92
|
"scroll-into-view-if-needed": "^3.1.0",
|
|
93
|
-
"shiki": "^4.0
|
|
93
|
+
"shiki": "^4.2.0",
|
|
94
94
|
"unified": "^11.0.5",
|
|
95
95
|
"unist-util-remove": "^4.0.0",
|
|
96
96
|
"unist-util-visit": "^5.1.0",
|
|
97
97
|
"unist-util-visit-children": "^3.0.0",
|
|
98
|
-
"@rspress/shared": "2.0.
|
|
98
|
+
"@rspress/shared": "2.0.15"
|
|
99
99
|
},
|
|
100
100
|
"devDependencies": {
|
|
101
|
-
"@microsoft/api-extractor": "^7.
|
|
102
|
-
"@rsbuild/plugin-sass": "~1.5.
|
|
103
|
-
"@rsbuild/plugin-svgr": "^2.0.
|
|
104
|
-
"@rslib/core": "0.
|
|
101
|
+
"@microsoft/api-extractor": "^7.58.9",
|
|
102
|
+
"@rsbuild/plugin-sass": "~1.5.3",
|
|
103
|
+
"@rsbuild/plugin-svgr": "^2.0.4",
|
|
104
|
+
"@rslib/core": "0.23.0",
|
|
105
105
|
"@types/body-scroll-lock": "^3.1.2",
|
|
106
106
|
"@types/hast": "^3.0.4",
|
|
107
107
|
"@types/mdast": "^4.0.4",
|
|
108
108
|
"@types/node": "^22.8.1",
|
|
109
109
|
"@types/nprogress": "^0.2.3",
|
|
110
|
-
"@types/react": "^19.2.
|
|
110
|
+
"@types/react": "^19.2.17",
|
|
111
111
|
"@types/react-dom": "^19.2.3",
|
|
112
112
|
"@types/react-reconciler": "^0.33.0",
|
|
113
|
-
"@types/web": "^0.0.
|
|
113
|
+
"@types/web": "^0.0.350",
|
|
114
114
|
"cac": "^7.0.0",
|
|
115
115
|
"chokidar": "^3.6.0",
|
|
116
116
|
"execa": "8.0.1",
|
|
117
117
|
"mdast-util-directive": "^3.1.0",
|
|
118
118
|
"mdast-util-mdx-expression": "^2.0.1",
|
|
119
|
-
"memfs": "^4.57.
|
|
119
|
+
"memfs": "^4.57.8",
|
|
120
120
|
"p-map": "^7.0.4",
|
|
121
121
|
"picocolors": "^1.1.1",
|
|
122
122
|
"postcss": "8.5.15",
|
|
123
123
|
"remark-directive": "^4.0.0",
|
|
124
|
-
"rsbuild-plugin-publint": "^0.
|
|
125
|
-
"rsbuild-plugin-virtual-module": "0.4.
|
|
126
|
-
"
|
|
127
|
-
"tinyglobby": "^0.2.16",
|
|
124
|
+
"rsbuild-plugin-publint": "^1.0.0",
|
|
125
|
+
"rsbuild-plugin-virtual-module": "0.4.4",
|
|
126
|
+
"tinyglobby": "^0.2.17",
|
|
128
127
|
"tinypool": "^1.1.1",
|
|
129
128
|
"ts-json-schema-generator": "^2.9.0",
|
|
130
129
|
"typescript": "^6.0.3",
|
package/dist/559.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { workerData } from "node:worker_threads";
|