@rspress/core 2.1.0-beta.1 → 2.1.0-beta.2
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/cli/index.js +2 -2
- package/dist/config/loadConfigFile.js +1 -1
- package/dist/eject-theme/components/CdnTabs/index.test.tsx +71 -0
- package/dist/eject-theme/components/CdnTabs/index.tsx +175 -0
- package/dist/eject-theme/components/DocContent/index.tsx +0 -3
- package/dist/eject-theme/components/FallbackHeading/index.tsx +6 -1
- package/dist/eject-theme/components/Link/index.tsx +9 -18
- package/dist/eject-theme/components/Link/useLinkNavigate.ts +17 -3
- package/dist/eject-theme/components/NavTitle/index.test.tsx +78 -0
- package/dist/eject-theme/components/NavTitle/index.tsx +9 -5
- package/dist/eject-theme/components/PackageManagerTabs/index.test.tsx +79 -1
- package/dist/eject-theme/components/PackageManagerTabs/index.tsx +25 -12
- package/dist/eject-theme/components/Search/NoSearchResult.scss +1 -2
- package/dist/eject-theme/components/Search/SearchPanel.scss +75 -63
- package/dist/eject-theme/components/Search/SuggestItem.scss +28 -41
- package/dist/eject-theme/components/Sidebar/SidebarItem.scss +8 -0
- package/dist/eject-theme/components/Sidebar/SidebarSectionHeader.scss +3 -0
- package/dist/node/PluginDriver.d.ts +5 -0
- package/dist/node/PluginDriver.js +14 -5
- 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.js +1 -1
- package/dist/node/constants.js +1 -1
- package/dist/node/eject.js +1 -1
- package/dist/node/initRsbuild.js +12 -4
- package/dist/node/mdx/rehypePlugins/headerAnchor.js +1 -0
- package/dist/node/mdx/remarkPlugins/link.js +1 -1
- package/dist/node/route/RoutePage.js +1 -1
- package/dist/node/route/RouteService.js +1 -1
- package/dist/node/route/extractPageData.js +1 -1
- package/dist/node/route/normalizeRoutePath.js +1 -1
- package/dist/node/runtimeModule/i18n/getI18nData.d.ts +11 -0
- package/dist/node/runtimeModule/{i18n.js → i18n/getI18nData.js} +35 -22
- package/dist/node/runtimeModule/i18n/rsbuildPlugin.d.ts +5 -0
- package/dist/node/runtimeModule/i18n/rsbuildPlugin.js +21 -0
- package/dist/node/runtimeModule/pageData/createPageData.js +1 -1
- package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
- package/dist/node/runtimeModule/searchHooks.js +1 -1
- package/dist/node/runtimeModule/siteData/createSiteData.d.ts +2 -1
- package/dist/node/runtimeModule/siteData/createSiteData.js +3 -3
- package/dist/node/runtimeModule/siteData/normalizeThemeConfig.d.ts +2 -1
- package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +3 -4
- package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +2 -2
- package/dist/node/serve.js +1 -1
- package/dist/node/sitemap.d.ts +7 -2
- package/dist/node/sitemap.js +40 -57
- package/dist/node/ssg/alternateLinks.js +1 -1
- package/dist/node/ssg/htmlFile.js +1 -1
- package/dist/node/ssg/renderHtmlTemplate.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 +2 -2
- package/dist/node/ssg/rsbuildPluginSSG.js +1 -1
- 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 +1 -1
- 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 +2 -2
- package/dist/{h~0.js → p~0.js} +6 -4
- package/dist/runtime/App.js +14 -10
- package/dist/runtime/BrowserOnly.d.ts +1 -1
- package/dist/runtime/BrowserOnly.js +53 -20
- package/dist/runtime/ClientApp.js +4 -0
- package/dist/runtime/NoSSR.d.ts +7 -3
- package/dist/runtime/NoSSR.js +30 -9
- package/dist/runtime/PageRoute.js +20 -8
- package/dist/runtime/index.d.ts +3 -2
- package/dist/runtime/index.js +3 -4
- package/dist/runtime/react.d.ts +5 -0
- package/dist/runtime/react.js +4 -0
- package/dist/runtime/reactDom.d.ts +6 -0
- package/dist/runtime/reactDom.js +2 -1
- package/dist/runtime/socialLinks.d.ts +1 -0
- package/dist/runtime/socialLinks.js +3 -0
- package/dist/theme/assets/bun.js +101 -0
- package/dist/theme/assets/deno.js +15 -0
- package/dist/theme/assets/jsdelivr.js +53 -0
- package/dist/theme/{components/PackageManagerTabs/icons/Npm.js → assets/npm.js} +4 -4
- package/dist/theme/{components/PackageManagerTabs/icons/Pnpm.js → assets/pnpm.js} +4 -4
- package/dist/theme/assets/unpkg.js +15 -0
- package/dist/theme/assets/yarn.js +22 -0
- package/dist/theme/components/CdnTabs/index.d.ts +10 -0
- package/dist/theme/components/CdnTabs/index.js +146 -0
- package/dist/theme/components/DocContent/index.js +1 -2
- package/dist/theme/components/FallbackHeading/index.js +1 -0
- package/dist/theme/components/Link/index.js +4 -13
- package/dist/theme/components/Link/useLinkNavigate.js +12 -4
- package/dist/theme/components/NavTitle/index.js +10 -5
- package/dist/theme/components/PackageManagerTabs/index.d.ts +2 -0
- package/dist/theme/components/PackageManagerTabs/index.js +22 -12
- package/dist/theme/components/Search/NoSearchResult.css +1 -2
- package/dist/theme/components/Search/SearchPanel.css +72 -51
- package/dist/theme/components/Search/SuggestItem.css +21 -34
- package/dist/theme/components/Sidebar/SidebarItem.css +5 -0
- package/dist/theme/components/Sidebar/SidebarSectionHeader.css +1 -0
- package/dist/theme/hooks/useDynamicToc.js +27 -34
- package/dist/theme/icons.d.ts +7 -0
- package/dist/theme/icons.js +15 -1
- package/dist/theme/index.d.ts +1 -2
- package/dist/theme/index.js +1 -2
- package/dist/theme/layout/Layout/index.js +1 -2
- package/dist/y~0.js +166 -0
- package/package.json +13 -13
- package/dist/b~0.js +0 -104
- package/dist/eject-theme/components/PackageManagerTabs/icons/Bun.tsx +0 -101
- package/dist/eject-theme/components/PackageManagerTabs/icons/Deno.tsx +0 -18
- package/dist/eject-theme/components/PackageManagerTabs/icons/Npm.tsx +0 -16
- package/dist/eject-theme/components/PackageManagerTabs/icons/Pnpm.tsx +0 -22
- package/dist/eject-theme/components/PackageManagerTabs/icons/Yarn.tsx +0 -18
- package/dist/node/runtimeModule/i18n.d.ts +0 -8
- package/dist/theme/components/PackageManagerTabs/icons/Bun.d.ts +0 -2
- package/dist/theme/components/PackageManagerTabs/icons/Bun.js +0 -137
- package/dist/theme/components/PackageManagerTabs/icons/Deno.d.ts +0 -2
- package/dist/theme/components/PackageManagerTabs/icons/Deno.js +0 -15
- package/dist/theme/components/PackageManagerTabs/icons/Npm.d.ts +0 -2
- package/dist/theme/components/PackageManagerTabs/icons/Pnpm.d.ts +0 -2
- package/dist/theme/components/PackageManagerTabs/icons/Yarn.d.ts +0 -2
- package/dist/theme/components/PackageManagerTabs/icons/Yarn.js +0 -22
- package/dist/theme/logic/useScrollAfterNav.d.ts +0 -5
- package/dist/theme/logic/useScrollAfterNav.js +0 -35
- package/dist/theme/logic/useScrollReset.d.ts +0 -5
- package/dist/theme/logic/useScrollReset.js +0 -12
- package/dist/tu~0.js +0 -3
- /package/dist/node/runtimeModule/{DEFAULT_I18N_TEXT.d.ts → i18n/DEFAULT_I18N_TEXT.d.ts} +0 -0
- /package/dist/node/runtimeModule/{DEFAULT_I18N_TEXT.js → i18n/DEFAULT_I18N_TEXT.js} +0 -0
|
@@ -22,29 +22,20 @@ const Link = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
22
22
|
...otherProps,
|
|
23
23
|
children: children
|
|
24
24
|
});
|
|
25
|
-
if ('hashOnly' === linkType) return /*#__PURE__*/ jsx("a", {
|
|
26
|
-
ref: ref,
|
|
27
|
-
href: href,
|
|
28
|
-
className: clsx(className, 'rp-link'),
|
|
29
|
-
onClick: onClick,
|
|
30
|
-
onMouseEnter: onMouseEnter,
|
|
31
|
-
...otherProps,
|
|
32
|
-
children: children
|
|
33
|
-
});
|
|
34
|
-
if ('relative' === linkType) return /*#__PURE__*/ jsx("a", {
|
|
25
|
+
if ('hashOnly' === linkType || 'relative' === linkType) return /*#__PURE__*/ jsx("a", {
|
|
35
26
|
ref: ref,
|
|
36
27
|
href: href,
|
|
37
28
|
className: clsx(className, 'rp-link'),
|
|
38
29
|
onMouseEnter: (event)=>{
|
|
39
30
|
onMouseEnter?.(event);
|
|
40
|
-
preloadLink(routePath);
|
|
31
|
+
if ('relative' === linkType) preloadLink(routePath);
|
|
41
32
|
},
|
|
42
33
|
onTouchStart: ()=>{
|
|
43
|
-
preloadLink(routePath);
|
|
34
|
+
if ('relative' === linkType) preloadLink(routePath);
|
|
44
35
|
},
|
|
45
36
|
onClick: (e)=>{
|
|
46
37
|
onClick?.(e);
|
|
47
|
-
if (0 !== e.button || e.currentTarget.target && '_self' !== e.currentTarget.target || e.metaKey || e.shiftKey || e.altKey || e.ctrlKey) return;
|
|
38
|
+
if (e.defaultPrevented || e.currentTarget.hasAttribute('download') || 0 !== e.button || e.currentTarget.target && '_self' !== e.currentTarget.target || e.metaKey || e.shiftKey || e.altKey || e.ctrlKey) return;
|
|
48
39
|
e.preventDefault();
|
|
49
40
|
navigate(href);
|
|
50
41
|
},
|
|
@@ -8,16 +8,24 @@ function useLinkNavigate({ startTransition } = {}) {
|
|
|
8
8
|
const useTransitions = site?.route?.useTransitions;
|
|
9
9
|
return useCallback(async (href)=>{
|
|
10
10
|
const { linkType, removeBaseHref, routePath, withBaseHref } = getHref(href);
|
|
11
|
-
if ('external' === linkType
|
|
12
|
-
if (!isActive(removeBaseHref, pathname) && !pathnameToRouteService(routePath)) return void window.location.assign(withBaseHref);
|
|
11
|
+
if ('external' === linkType) return void window.location.assign(href);
|
|
12
|
+
if ('hashOnly' !== linkType && !isActive(removeBaseHref, pathname) && !pathnameToRouteService(routePath)) return void window.location.assign(withBaseHref);
|
|
13
|
+
const hashUrl = 'hashOnly' === linkType ? new URL(href, window.location.href) : void 0;
|
|
14
|
+
const to = hashUrl ? {
|
|
15
|
+
search: hashUrl.search,
|
|
16
|
+
hash: hashUrl.hash
|
|
17
|
+
} : removeBaseHref;
|
|
18
|
+
const options = hashUrl ? {
|
|
19
|
+
replace: hashUrl.href === window.location.href
|
|
20
|
+
} : void 0;
|
|
13
21
|
if (useTransitions && startTransition) {
|
|
14
22
|
let navigation;
|
|
15
23
|
startTransition(()=>{
|
|
16
|
-
navigation = navigate(
|
|
24
|
+
navigation = navigate(to, options);
|
|
17
25
|
return navigation;
|
|
18
26
|
});
|
|
19
27
|
await navigation;
|
|
20
|
-
} else await navigate(
|
|
28
|
+
} else await navigate(to, options);
|
|
21
29
|
}, [
|
|
22
30
|
useTransitions,
|
|
23
31
|
pathname,
|
|
@@ -13,11 +13,12 @@ const NavTitle = ()=>{
|
|
|
13
13
|
const title = (localeInfo?.title ?? site.title) || 'Home';
|
|
14
14
|
const langRoutePrefix = lang === defaultLang ? '/' : addTrailingSlash(lang);
|
|
15
15
|
const { logo: rawLogo, logoText, logoHref } = site;
|
|
16
|
+
const alt = logoText ? '' : title;
|
|
16
17
|
const logo = useMemo(()=>{
|
|
17
18
|
if (!rawLogo) return null;
|
|
18
19
|
if ('string' == typeof rawLogo) return /*#__PURE__*/ jsx("img", {
|
|
19
20
|
src: normalizeImagePath(rawLogo),
|
|
20
|
-
alt:
|
|
21
|
+
alt: alt,
|
|
21
22
|
id: "logo",
|
|
22
23
|
className: "rspress-logo rp-nav__title__logo-image"
|
|
23
24
|
});
|
|
@@ -25,20 +26,24 @@ const NavTitle = ()=>{
|
|
|
25
26
|
children: [
|
|
26
27
|
/*#__PURE__*/ jsx("img", {
|
|
27
28
|
src: normalizeImagePath(rawLogo.light),
|
|
28
|
-
alt:
|
|
29
|
+
alt: alt,
|
|
29
30
|
id: "logo",
|
|
31
|
+
width: rawLogo.width,
|
|
32
|
+
height: rawLogo.height,
|
|
30
33
|
className: "rspress-logo rp-nav__title__logo-image rp-nav__title__logo-image--light"
|
|
31
34
|
}),
|
|
32
35
|
/*#__PURE__*/ jsx("img", {
|
|
33
36
|
src: normalizeImagePath(rawLogo.dark),
|
|
34
|
-
alt:
|
|
35
|
-
|
|
37
|
+
alt: alt,
|
|
38
|
+
width: rawLogo.width,
|
|
39
|
+
height: rawLogo.height,
|
|
36
40
|
className: "rspress-logo rp-nav__title__logo-image rp-nav__title__logo-image--dark"
|
|
37
41
|
})
|
|
38
42
|
]
|
|
39
43
|
});
|
|
40
44
|
}, [
|
|
41
|
-
rawLogo
|
|
45
|
+
rawLogo,
|
|
46
|
+
alt
|
|
42
47
|
]);
|
|
43
48
|
return /*#__PURE__*/ jsx("div", {
|
|
44
49
|
className: "rp-nav__title",
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Tab, Tabs, getCustomMDXComponent } from "@rspress/core/theme";
|
|
2
|
+
import { IconBun, IconDeno, IconNpm, IconPnpm, IconYarn, SvgWrapper, Tab, Tabs, getCustomMDXComponent } from "@rspress/core/theme";
|
|
3
3
|
import { useMemo } from "react";
|
|
4
|
-
import { Bun } from "./icons/Bun.js";
|
|
5
|
-
import { Deno } from "./icons/Deno.js";
|
|
6
|
-
import { Npm } from "./icons/Npm.js";
|
|
7
|
-
import { Pnpm } from "./icons/Pnpm.js";
|
|
8
|
-
import { Yarn } from "./icons/Yarn.js";
|
|
9
4
|
const transformDenoPositional = (cmd)=>{
|
|
10
5
|
const parts = cmd.split(' ');
|
|
11
6
|
const subcommand = parts[1];
|
|
@@ -52,11 +47,21 @@ function splitTo2Parts(command) {
|
|
|
52
47
|
function PackageManagerTabs({ command, exec, dlx, additionalTabs = [] }) {
|
|
53
48
|
let commandInfo;
|
|
54
49
|
const packageMangerToIcon = {
|
|
55
|
-
npm: /*#__PURE__*/ jsx(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
50
|
+
npm: /*#__PURE__*/ jsx(SvgWrapper, {
|
|
51
|
+
icon: IconNpm
|
|
52
|
+
}),
|
|
53
|
+
yarn: /*#__PURE__*/ jsx(SvgWrapper, {
|
|
54
|
+
icon: IconYarn
|
|
55
|
+
}),
|
|
56
|
+
pnpm: /*#__PURE__*/ jsx(SvgWrapper, {
|
|
57
|
+
icon: IconPnpm
|
|
58
|
+
}),
|
|
59
|
+
bun: /*#__PURE__*/ jsx(SvgWrapper, {
|
|
60
|
+
icon: IconBun
|
|
61
|
+
}),
|
|
62
|
+
deno: /*#__PURE__*/ jsx(SvgWrapper, {
|
|
63
|
+
icon: IconDeno
|
|
64
|
+
})
|
|
60
65
|
};
|
|
61
66
|
additionalTabs.forEach((tab)=>{
|
|
62
67
|
packageMangerToIcon[tab.tool] = tab.icon;
|
|
@@ -110,7 +115,12 @@ function PackageManagerTabs({ command, exec, dlx, additionalTabs = [] }) {
|
|
|
110
115
|
commandInfo.pnpm = normalizeCommand(commandInfo.pnpm);
|
|
111
116
|
commandInfo.bun = normalizeCommand(commandInfo.bun);
|
|
112
117
|
commandInfo.deno = normalizeCommand(commandInfo.deno);
|
|
113
|
-
} else commandInfo =
|
|
118
|
+
} else commandInfo = {
|
|
119
|
+
...command
|
|
120
|
+
};
|
|
121
|
+
additionalTabs.forEach((tab)=>{
|
|
122
|
+
if (void 0 !== tab.command) commandInfo[tab.tool] = tab.command;
|
|
123
|
+
});
|
|
114
124
|
if (import.meta.env.SSG_MD) return Object.values(commandInfo).reduce((previous, current)=>{
|
|
115
125
|
const [packageManager, command] = splitTo2Parts(current);
|
|
116
126
|
return previous + `\n\`\`\`sh [${packageManager}]\n` + `${packageManager}${command}\n` + "```\n";
|
|
@@ -7,14 +7,20 @@
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
.rp-search-panel__modal {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
--rp-search-panel-top: min(80px, 10dvh);
|
|
11
|
+
margin: calc(var(--rp-search-panel-top) + env(safe-area-inset-top, 0px)) auto auto;
|
|
12
|
+
width: calc(100% - 48px);
|
|
13
|
+
max-width: 640px;
|
|
14
|
+
max-height: calc(100dvh - var(--rp-search-panel-top) - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
|
|
15
|
+
border: 1px solid var(--rp-c-divider-light);
|
|
16
|
+
background-color: var(--rp-c-bg);
|
|
17
|
+
border-radius: 16px;
|
|
18
|
+
flex-direction: column;
|
|
16
19
|
animation: .18s ease-out rp-search-panel-in;
|
|
20
|
+
display: flex;
|
|
17
21
|
position: relative;
|
|
22
|
+
overflow: hidden;
|
|
23
|
+
box-shadow: 0 16px 48px #0003;
|
|
18
24
|
}
|
|
19
25
|
|
|
20
26
|
@media (prefers-reduced-motion: reduce) {
|
|
@@ -23,48 +29,85 @@
|
|
|
23
29
|
}
|
|
24
30
|
}
|
|
25
31
|
|
|
32
|
+
@media (width <= 768px) {
|
|
33
|
+
.rp-search-panel__modal {
|
|
34
|
+
--rp-search-panel-top: 24px;
|
|
35
|
+
width: calc(100% - 24px);
|
|
36
|
+
max-width: 560px;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
26
40
|
.rp-search-panel__header {
|
|
41
|
+
flex-shrink: 0;
|
|
27
42
|
align-items: center;
|
|
43
|
+
gap: 8px;
|
|
44
|
+
padding: 12px 20px;
|
|
28
45
|
display: flex;
|
|
29
46
|
}
|
|
30
47
|
|
|
48
|
+
@media (width <= 768px) {
|
|
49
|
+
.rp-search-panel__header {
|
|
50
|
+
padding: 8px 12px;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
31
54
|
.rp-search-panel__cancel {
|
|
32
55
|
color: var(--rp-c-brand);
|
|
33
56
|
cursor: pointer;
|
|
34
57
|
white-space: nowrap;
|
|
35
|
-
|
|
58
|
+
display: none;
|
|
36
59
|
}
|
|
37
60
|
|
|
38
|
-
@media (width
|
|
61
|
+
@media (width <= 768px) {
|
|
39
62
|
.rp-search-panel__cancel {
|
|
40
|
-
|
|
63
|
+
flex-shrink: 0;
|
|
64
|
+
align-items: center;
|
|
65
|
+
min-height: 44px;
|
|
66
|
+
margin: 0;
|
|
67
|
+
padding: 0 4px;
|
|
68
|
+
font-size: 14px;
|
|
69
|
+
font-weight: 500;
|
|
70
|
+
display: flex;
|
|
41
71
|
}
|
|
42
72
|
}
|
|
43
73
|
|
|
44
74
|
.rp-search-panel__input-form {
|
|
45
|
-
|
|
46
|
-
border: 1px solid var(--rp-c-brand);
|
|
47
|
-
border-radius: var(--rp-radius-small);
|
|
75
|
+
flex: 1;
|
|
48
76
|
align-items: center;
|
|
49
|
-
width:
|
|
50
|
-
height:
|
|
51
|
-
padding: 0 12px;
|
|
77
|
+
min-width: 0;
|
|
78
|
+
height: 48px;
|
|
52
79
|
display: flex;
|
|
53
80
|
}
|
|
54
81
|
|
|
82
|
+
@media (width <= 768px) {
|
|
83
|
+
.rp-search-panel__input-form {
|
|
84
|
+
height: 44px;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
55
88
|
.rp-search-panel__input {
|
|
56
89
|
background-color: var(--rp-c-bg);
|
|
90
|
+
min-width: 0;
|
|
91
|
+
height: 100%;
|
|
92
|
+
color: var(--rp-c-text-1);
|
|
57
93
|
outline: none;
|
|
58
94
|
flex: 1;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
font-size: 20px;
|
|
63
|
-
font-weight: 500;
|
|
95
|
+
padding-left: 10px;
|
|
96
|
+
font-size: 18px;
|
|
97
|
+
font-weight: 400;
|
|
64
98
|
}
|
|
65
99
|
|
|
66
|
-
|
|
67
|
-
|
|
100
|
+
@media (width <= 768px) {
|
|
101
|
+
.rp-search-panel__input {
|
|
102
|
+
font-size: 16px;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.rp-search-panel__search-icon, .rp-search-panel__close {
|
|
107
|
+
width: 20px;
|
|
108
|
+
height: 20px;
|
|
109
|
+
color: var(--rp-c-text-2);
|
|
110
|
+
display: block;
|
|
68
111
|
}
|
|
69
112
|
|
|
70
113
|
.rp-search-panel__close:hover {
|
|
@@ -83,15 +126,12 @@
|
|
|
83
126
|
}
|
|
84
127
|
}
|
|
85
128
|
|
|
86
|
-
.rp-search-panel__search-icon {
|
|
87
|
-
font-size: 20px;
|
|
88
|
-
display: inline-block;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
129
|
.rp-search-panel__results {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
130
|
+
border-top: 1px solid var(--rp-c-divider-light);
|
|
131
|
+
overscroll-behavior: contain;
|
|
132
|
+
min-height: 0;
|
|
133
|
+
padding: 8px;
|
|
134
|
+
overflow: auto;
|
|
95
135
|
}
|
|
96
136
|
|
|
97
137
|
.rp-search-panel__error {
|
|
@@ -101,7 +141,7 @@
|
|
|
101
141
|
}
|
|
102
142
|
|
|
103
143
|
.rp-search-panel__tabs {
|
|
104
|
-
background-color: var(--rp-c-bg
|
|
144
|
+
background-color: var(--rp-c-bg);
|
|
105
145
|
padding-bottom: 6px;
|
|
106
146
|
position: sticky;
|
|
107
147
|
}
|
|
@@ -113,26 +153,7 @@
|
|
|
113
153
|
}
|
|
114
154
|
|
|
115
155
|
.rp-search-panel__group {
|
|
116
|
-
padding-bottom:
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
@media (width <= 960px) {
|
|
120
|
-
.rp-search-panel__modal {
|
|
121
|
-
margin-top: calc(32px + env(safe-area-inset-top, 0px));
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
.rp-search-panel__input-form {
|
|
125
|
-
height: 40px;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
.rp-search-panel__search-icon, .rp-search-panel__close {
|
|
129
|
-
width: 16px;
|
|
130
|
-
height: 16px;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
.rp-search-panel__input {
|
|
134
|
-
font-size: 16px;
|
|
135
|
-
}
|
|
156
|
+
padding-bottom: 4px;
|
|
136
157
|
}
|
|
137
158
|
|
|
138
159
|
@keyframes rp-search-panel-in {
|
|
@@ -1,48 +1,16 @@
|
|
|
1
1
|
.rp-suggest-item {
|
|
2
2
|
box-sizing: border-box;
|
|
3
|
-
margin:
|
|
3
|
+
margin: 4px 0;
|
|
4
4
|
list-style: none;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
.
|
|
8
|
-
box-shadow: none;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.rp-suggest-item .rp-suggest-item__link {
|
|
7
|
+
.rp-suggest-item__link {
|
|
12
8
|
color: var(--rp-c-text-1);
|
|
13
9
|
background-color: var(--rp-c-bg);
|
|
14
10
|
border-radius: var(--rp-radius-small);
|
|
15
11
|
width: 100%;
|
|
16
12
|
padding-left: 12px;
|
|
17
13
|
display: flex;
|
|
18
|
-
box-shadow: 0 1px 3px #d4d9e1;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.rp-suggest-item--current .rp-suggest-item__link {
|
|
22
|
-
background-color: var(--rp-c-brand);
|
|
23
|
-
cursor: pointer;
|
|
24
|
-
color: #fff;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.rp-suggest-item--current .rp-suggest-item__container .rp-suggest-item__icon {
|
|
28
|
-
color: #fff;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.rp-suggest-item--current .rp-suggest-item__container .rp-suggest-item__action-icon {
|
|
32
|
-
opacity: 1;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.rp-suggest-item--current .rp-suggest-item__container .rp-suggest-item__content .rp-suggest-item__statement {
|
|
36
|
-
color: #fff;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.rp-suggest-item--current .rp-suggest-item__container .rp-suggest-item__content .rp-suggest-item__mark {
|
|
40
|
-
color: #fff;
|
|
41
|
-
text-decoration: underline;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.rp-suggest-item--current .rp-suggest-item__container .rp-suggest-item__content .rp-suggest-item__title {
|
|
45
|
-
color: #fff;
|
|
46
14
|
}
|
|
47
15
|
|
|
48
16
|
.rp-suggest-item__container {
|
|
@@ -59,7 +27,9 @@
|
|
|
59
27
|
}
|
|
60
28
|
|
|
61
29
|
.rp-suggest-item__content {
|
|
30
|
+
overflow-wrap: anywhere;
|
|
62
31
|
width: 100%;
|
|
32
|
+
min-width: 0;
|
|
63
33
|
padding: 6px 8px;
|
|
64
34
|
font-size: 14px;
|
|
65
35
|
line-height: 1.5;
|
|
@@ -88,3 +58,20 @@
|
|
|
88
58
|
opacity: 0;
|
|
89
59
|
}
|
|
90
60
|
|
|
61
|
+
.rp-suggest-item--current .rp-suggest-item__link {
|
|
62
|
+
background-color: var(--rp-c-brand);
|
|
63
|
+
cursor: pointer;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.rp-suggest-item--current .rp-suggest-item__link, .rp-suggest-item--current .rp-suggest-item__icon, .rp-suggest-item--current .rp-suggest-item__statement, .rp-suggest-item--current .rp-suggest-item__mark, .rp-suggest-item--current .rp-suggest-item__title {
|
|
67
|
+
color: #fff;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.rp-suggest-item--current .rp-suggest-item__mark {
|
|
71
|
+
text-decoration: underline;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.rp-suggest-item--current .rp-suggest-item__action-icon {
|
|
75
|
+
opacity: 1;
|
|
76
|
+
}
|
|
77
|
+
|
|
@@ -65,11 +65,16 @@
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
.rp-sidebar-item__left {
|
|
68
|
+
overflow-wrap: anywhere;
|
|
68
69
|
align-items: center;
|
|
69
70
|
gap: 4px;
|
|
70
71
|
display: flex;
|
|
71
72
|
}
|
|
72
73
|
|
|
74
|
+
.rp-sidebar-item__left > .rp-doc code {
|
|
75
|
+
overflow-wrap: anywhere;
|
|
76
|
+
}
|
|
77
|
+
|
|
73
78
|
.rp-sidebar-item__icon {
|
|
74
79
|
object-fit: contain;
|
|
75
80
|
flex: 0 0 16px;
|
|
@@ -1,29 +1,18 @@
|
|
|
1
|
-
import { usePage } from "@rspress/core/runtime";
|
|
2
|
-
import { useCallback, useEffect, useState } from "react";
|
|
1
|
+
import { useLocation, usePage } from "@rspress/core/runtime";
|
|
2
|
+
import { useCallback, useEffect, useState, useSyncExternalStore } from "react";
|
|
3
3
|
import { processTitleElement } from "./processTitleElement.js";
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const distributeUpdate = ()=>{
|
|
10
|
-
for (const fn of Object.values(updateFns))fn();
|
|
11
|
-
};
|
|
12
|
-
const useSubScribe = ()=>{
|
|
13
|
-
const forceUpdate = useForceUpdate();
|
|
14
|
-
useEffect(()=>{
|
|
15
|
-
const id = Math.random().toString(36).slice(2);
|
|
16
|
-
updateFns[id] = forceUpdate;
|
|
17
|
-
return ()=>{
|
|
18
|
-
delete updateFns[id];
|
|
19
|
-
};
|
|
20
|
-
}, [
|
|
21
|
-
forceUpdate
|
|
22
|
-
]);
|
|
23
|
-
};
|
|
24
|
-
const headers = {
|
|
25
|
-
current: []
|
|
4
|
+
let tocSnapshot;
|
|
5
|
+
const listeners = new Set();
|
|
6
|
+
const subscribe = (listener)=>{
|
|
7
|
+
listeners.add(listener);
|
|
8
|
+
return ()=>listeners.delete(listener);
|
|
26
9
|
};
|
|
10
|
+
const getSnapshot = ()=>tocSnapshot;
|
|
11
|
+
const getServerSnapshot = ()=>void 0;
|
|
12
|
+
function setSnapshot(snapshot) {
|
|
13
|
+
tocSnapshot = snapshot;
|
|
14
|
+
for (const listener of listeners)listener();
|
|
15
|
+
}
|
|
27
16
|
function isElementOnlyVisible(element) {
|
|
28
17
|
const style = window.getComputedStyle(element);
|
|
29
18
|
return 'none' !== style.display && '0' !== style.opacity && 'hidden' !== style.visibility;
|
|
@@ -40,10 +29,11 @@ function isElementVisible(element) {
|
|
|
40
29
|
}
|
|
41
30
|
const useDynamicToc = ()=>{
|
|
42
31
|
const { page: { toc = [] } } = usePage();
|
|
43
|
-
|
|
44
|
-
|
|
32
|
+
const { pathname } = useLocation();
|
|
33
|
+
const snapshot = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
34
|
+
return snapshot?.pathname === pathname ? snapshot.headers : toc;
|
|
45
35
|
};
|
|
46
|
-
function updateHeaders(target) {
|
|
36
|
+
function updateHeaders(target, pathname) {
|
|
47
37
|
const collectedHeaders = [];
|
|
48
38
|
const elements = target?.querySelectorAll('.rspress-doc h2.rp-toc-include, h3.rp-toc-include, h4.rp-toc-include');
|
|
49
39
|
elements?.forEach((el)=>{
|
|
@@ -54,10 +44,10 @@ function updateHeaders(target) {
|
|
|
54
44
|
charIndex: 0
|
|
55
45
|
});
|
|
56
46
|
});
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
47
|
+
setSnapshot({
|
|
48
|
+
pathname,
|
|
49
|
+
headers: collectedHeaders
|
|
50
|
+
});
|
|
61
51
|
}
|
|
62
52
|
const TOC_HEADING_TAGS = new Set([
|
|
63
53
|
'H2',
|
|
@@ -66,10 +56,11 @@ const TOC_HEADING_TAGS = new Set([
|
|
|
66
56
|
]);
|
|
67
57
|
const useWatchToc = ()=>{
|
|
68
58
|
const [innerRef, setRef] = useState(null);
|
|
59
|
+
const { pathname } = useLocation();
|
|
69
60
|
useEffect(()=>{
|
|
70
61
|
let observer = null;
|
|
71
62
|
const target = innerRef;
|
|
72
|
-
if (target) updateHeaders(target);
|
|
63
|
+
if (target) updateHeaders(target, pathname);
|
|
73
64
|
if (target && !observer) {
|
|
74
65
|
observer = new MutationObserver((mutationList)=>{
|
|
75
66
|
let needUpdate = false;
|
|
@@ -86,7 +77,7 @@ const useWatchToc = ()=>{
|
|
|
86
77
|
break check;
|
|
87
78
|
}
|
|
88
79
|
}
|
|
89
|
-
needUpdate && updateHeaders(target);
|
|
80
|
+
needUpdate && updateHeaders(target, pathname);
|
|
90
81
|
});
|
|
91
82
|
observer.observe(target, {
|
|
92
83
|
childList: true,
|
|
@@ -96,9 +87,11 @@ const useWatchToc = ()=>{
|
|
|
96
87
|
return ()=>{
|
|
97
88
|
observer?.disconnect();
|
|
98
89
|
observer = null;
|
|
90
|
+
setSnapshot(void 0);
|
|
99
91
|
};
|
|
100
92
|
}, [
|
|
101
|
-
innerRef
|
|
93
|
+
innerRef,
|
|
94
|
+
pathname
|
|
102
95
|
]);
|
|
103
96
|
const rspressDocRef = useCallback((ref)=>{
|
|
104
97
|
setRef(ref);
|
package/dist/theme/icons.d.ts
CHANGED
|
@@ -6,8 +6,10 @@ export declare const IconOpenInChat: Icon;
|
|
|
6
6
|
export declare const IconArrowDown: Icon;
|
|
7
7
|
export declare const IconArrowRight: Icon;
|
|
8
8
|
export declare const IconAnthropic: Icon;
|
|
9
|
+
export declare const IconBun: Icon;
|
|
9
10
|
export declare const IconClose: Icon;
|
|
10
11
|
export declare const IconCopy: Icon;
|
|
12
|
+
export declare const IconDeno: Icon;
|
|
11
13
|
export declare const IconDown: Icon;
|
|
12
14
|
export declare const IconEdit: Icon;
|
|
13
15
|
export declare const IconEmpty: Icon;
|
|
@@ -15,18 +17,23 @@ export declare const IconFile: Icon;
|
|
|
15
17
|
export declare const IconGithub: Icon;
|
|
16
18
|
export declare const IconGitlab: Icon;
|
|
17
19
|
export declare const IconHeader: Icon;
|
|
20
|
+
export declare const IconJsdelivr: Icon;
|
|
18
21
|
export declare const IconJump: Icon;
|
|
19
22
|
export declare const IconLoading: Icon;
|
|
20
23
|
export declare const IconMenu: Icon;
|
|
21
24
|
export declare const IconMoon: Icon;
|
|
25
|
+
export declare const IconNpm: Icon;
|
|
22
26
|
export declare const IconOpenAI: Icon;
|
|
27
|
+
export declare const IconPnpm: Icon;
|
|
23
28
|
export declare const IconScrollToTop: Icon;
|
|
24
29
|
export declare const IconSearch: Icon;
|
|
25
30
|
export declare const IconSmallMenu: Icon;
|
|
26
31
|
export declare const IconSuccess: Icon;
|
|
27
32
|
export declare const IconSun: Icon;
|
|
28
33
|
export declare const IconTitle: Icon;
|
|
34
|
+
export declare const IconUnpkg: Icon;
|
|
29
35
|
export declare const IconWrap: Icon;
|
|
30
36
|
export declare const IconWrapped: Icon;
|
|
37
|
+
export declare const IconYarn: Icon;
|
|
31
38
|
export declare const IconLink: Icon;
|
|
32
39
|
export {};
|