@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
package/dist/0~execa.js
CHANGED
|
@@ -8,7 +8,7 @@ import { createReadStream, createWriteStream, readFileSync } from "node:fs";
|
|
|
8
8
|
import { setTimeout as promises_setTimeout } from "node:timers/promises";
|
|
9
9
|
import { debuglog } from "node:util";
|
|
10
10
|
import { __webpack_require__ } from "./0~rslib-runtime.js";
|
|
11
|
-
import "./
|
|
11
|
+
import "./6010.js";
|
|
12
12
|
__webpack_require__.add({
|
|
13
13
|
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
14
14
|
const cp = __webpack_require__("child_process");
|
package/dist/0~rslib-runtime.js
CHANGED
|
@@ -20,11 +20,15 @@ __webpack_require__.m = __webpack_modules__;
|
|
|
20
20
|
};
|
|
21
21
|
})();
|
|
22
22
|
(()=>{
|
|
23
|
-
__webpack_require__.d = (exports,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
__webpack_require__.d = (exports, getters, values)=>{
|
|
24
|
+
var define = (defs, kind)=>{
|
|
25
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
[kind]: defs[key]
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
define(getters, "get");
|
|
31
|
+
define(values, "value");
|
|
28
32
|
};
|
|
29
33
|
})();
|
|
30
34
|
(()=>{
|
package/dist/3358.js
CHANGED
|
@@ -4,5 +4,5 @@ export { cwd } from "node:process";
|
|
|
4
4
|
export { logger } from "@rspress/shared/logger";
|
|
5
5
|
export { visit } from "unist-util-visit";
|
|
6
6
|
export { existsSync } from "node:fs";
|
|
7
|
-
export { addLeadingSlash, isDataUrl, isExternalUrl, isProduction, normalizeHref, parseUrl, withBase } from "@rspress/shared";
|
|
7
|
+
export { MDX_OR_MD_REGEXP, addLeadingSlash, isDataUrl, isExternalUrl, isProduction, normalizeHref, parseUrl, withBase } from "@rspress/shared";
|
|
8
8
|
export { getNodeAttribute } from "@rspress/shared/node-utils";
|
package/dist/5580.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! LICENSE: 5580.js.LICENSE.txt */
|
|
2
2
|
import { __webpack_require__ } from "./0~rslib-runtime.js";
|
|
3
|
-
import "./
|
|
3
|
+
import "./6010.js";
|
|
4
4
|
import { createRequire as __rspack_createRequire } from "node:module";
|
|
5
5
|
const __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
|
|
6
6
|
__webpack_require__.add({
|
|
@@ -4268,7 +4268,7 @@ __webpack_require__.add({
|
|
|
4268
4268
|
module.exports = __rspack_createRequire_require("util");
|
|
4269
4269
|
},
|
|
4270
4270
|
"../../node_modules/.pnpm/binary-extensions@2.3.0/node_modules/binary-extensions/binary-extensions.json" (module) {
|
|
4271
|
-
module.exports = JSON.parse('["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]');
|
|
4271
|
+
module.exports = /*#__PURE__*/ JSON.parse('["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]');
|
|
4272
4272
|
}
|
|
4273
4273
|
});
|
|
4274
4274
|
function toArr(any) {
|
package/dist/{2633.js → 6010.js}
RENAMED
|
@@ -2128,6 +2128,7 @@ var Builder = class {
|
|
|
2128
2128
|
const picomatch = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/index.js");
|
|
2129
2129
|
const isReadonlyArray = Array.isArray;
|
|
2130
2130
|
const BACKSLASHES = /\\/g;
|
|
2131
|
+
const DRIVE_RELATIVE_PATH = /^[A-Za-z]:$/;
|
|
2131
2132
|
const isWin = "win32" === process.platform;
|
|
2132
2133
|
const ONLY_PARENT_DIRECTORIES = /^(\/?\.\.)+$/;
|
|
2133
2134
|
function getPartialMatcher(patterns, options = {}) {
|
|
@@ -2193,6 +2194,9 @@ function buildRelative(cwd, root) {
|
|
|
2193
2194
|
return "/" === p[p.length - 1] && "" !== result ? `${result}/` : result || ".";
|
|
2194
2195
|
};
|
|
2195
2196
|
}
|
|
2197
|
+
function ensureNonDriveRelativePath(path) {
|
|
2198
|
+
return path.replace(DRIVE_RELATIVE_PATH, (match)=>`${match}/`);
|
|
2199
|
+
}
|
|
2196
2200
|
const splitPatternOptions = {
|
|
2197
2201
|
parts: true
|
|
2198
2202
|
};
|
|
@@ -2243,7 +2247,7 @@ function normalizePattern(pattern, opts, props, isIgnore) {
|
|
|
2243
2247
|
}
|
|
2244
2248
|
const potentialRoot = posix.join(cwd, parentDir.slice(3 * i));
|
|
2245
2249
|
if ("." !== potentialRoot[0] && props.root.length > potentialRoot.length) {
|
|
2246
|
-
props.root = potentialRoot;
|
|
2250
|
+
props.root = ensureNonDriveRelativePath(potentialRoot);
|
|
2247
2251
|
props.depthOffset = -n + i;
|
|
2248
2252
|
}
|
|
2249
2253
|
}
|
|
@@ -2262,7 +2266,7 @@ function normalizePattern(pattern, opts, props, isIgnore) {
|
|
|
2262
2266
|
}
|
|
2263
2267
|
props.depthOffset = newCommonPath.length;
|
|
2264
2268
|
props.commonPath = newCommonPath;
|
|
2265
|
-
props.root = newCommonPath.length > 0 ? posix.join(cwd, ...newCommonPath) : cwd;
|
|
2269
|
+
props.root = ensureNonDriveRelativePath(newCommonPath.length > 0 ? posix.join(cwd, ...newCommonPath) : cwd);
|
|
2266
2270
|
}
|
|
2267
2271
|
return result;
|
|
2268
2272
|
}
|
|
@@ -2354,18 +2358,17 @@ function formatPaths(paths, mapper) {
|
|
|
2354
2358
|
}
|
|
2355
2359
|
const defaultOptions = {
|
|
2356
2360
|
caseSensitiveMatch: true,
|
|
2357
|
-
cwd: process.cwd(),
|
|
2358
2361
|
debug: !!process.env.TINYGLOBBY_DEBUG,
|
|
2359
2362
|
expandDirectories: true,
|
|
2360
2363
|
followSymbolicLinks: true,
|
|
2361
2364
|
onlyFiles: true
|
|
2362
2365
|
};
|
|
2363
2366
|
function getOptions(options) {
|
|
2364
|
-
const opts = {
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
};
|
|
2368
|
-
opts.cwd = (opts.cwd instanceof URL ? fileURLToPath(opts.cwd) : resolve(opts.cwd)).replace(BACKSLASHES, "/");
|
|
2367
|
+
const opts = Object.assign({}, options);
|
|
2368
|
+
for(const key in defaultOptions)if (void 0 === opts[key]) Object.assign(opts, {
|
|
2369
|
+
[key]: defaultOptions[key]
|
|
2370
|
+
});
|
|
2371
|
+
opts.cwd = (opts.cwd instanceof URL ? fileURLToPath(opts.cwd) : resolve(opts.cwd || process.cwd())).replace(BACKSLASHES, "/");
|
|
2369
2372
|
opts.ignore = ensureStringArray(opts.ignore);
|
|
2370
2373
|
opts.fs && (opts.fs = {
|
|
2371
2374
|
readdir: opts.fs.readdir || readdir,
|
|
@@ -2436,7 +2439,7 @@ const pluginVirtualModule = (pluginOptions = {})=>({
|
|
|
2436
2439
|
});
|
|
2437
2440
|
export { DEFAULT_PAGE_EXTENSIONS } from "@rspress/shared/constants";
|
|
2438
2441
|
export { default as promises, mkdir, readdir as promises_readdir, rm, stat as promises_stat, writeFile } from "node:fs/promises";
|
|
2439
|
-
export { MDX_OR_MD_REGEXP, RSPRESS_TEMP_DIR, SEARCH_INDEX_NAME, addLeadingSlash, addTrailingSlash, getSidebarDataGroup, isDebugMode, isExternalUrl, normalizeHref, removeLeadingSlash, removeTrailingSlash, slash, withBase } from "@rspress/shared";
|
|
2442
|
+
export { MDX_OR_MD_REGEXP, RSPRESS_TEMP_DIR, SEARCH_INDEX_NAME, addLeadingSlash, addTrailingSlash, getSidebarDataGroup, isDebugMode, isExternalUrl, isProduction, normalizeDarkMode, normalizeHref, removeLeadingSlash, removeTrailingSlash, slash, withBase } from "@rspress/shared";
|
|
2440
2443
|
export { logger } from "@rspress/shared/logger";
|
|
2441
2444
|
export { extractTextAndId, getIconUrlPath, loadFrontMatter } from "@rspress/shared/node-utils";
|
|
2442
2445
|
export { createRequire as external_node_module_createRequire } from "node:module";
|
package/dist/6646.js
ADDED
package/dist/8005.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { default as node_os } from "node:os";
|
|
2
2
|
export { default as node_path } from "node:path";
|
|
3
|
-
export { default as github_slugger } from "@rspress/shared/github-slugger";
|
|
3
|
+
export { default as github_slugger, slug } from "@rspress/shared/github-slugger";
|
|
4
4
|
export { extractTextAndId } from "@rspress/shared/node-utils";
|
|
5
5
|
export { visitChildren } from "unist-util-visit-children";
|
package/dist/{7275.js → 9958.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var package_namespaceObject = {
|
|
2
|
-
rE: "2.0.
|
|
2
|
+
rE: "2.0.15"
|
|
3
3
|
};
|
|
4
4
|
async function pMap(iterable, mapper, { concurrency = 1 / 0, stopOnError = true, signal } = {}) {
|
|
5
5
|
return new Promise((resolve_, reject_)=>{
|
|
@@ -92,8 +92,9 @@ async function pMap(iterable, mapper, { concurrency = 1 / 0, stopOnError = true,
|
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
94
|
const pMapSkip = Symbol('skip');
|
|
95
|
+
export { getDefaultDarkModeValue, isDarkModeSwitchEnabled } from "@rspress/shared";
|
|
95
96
|
export { createRequire } from "node:module";
|
|
96
|
-
export { default as node_path } from "node:path";
|
|
97
|
+
export { default as node_path, isAbsolute, relative, resolve as external_node_path_resolve } from "node:path";
|
|
97
98
|
export { pathToFileURL } from "node:url";
|
|
98
99
|
export { logger } from "@rspress/shared/logger";
|
|
99
100
|
export { createHead, transformHtmlTemplate } from "@unhead/react/server";
|
package/dist/cli/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __webpack_require__ } from "../0~rslib-runtime.js";
|
|
2
2
|
import { node_path, logger, join, cac } from "../5580.js";
|
|
3
3
|
import "../7986.js";
|
|
4
|
-
import { package_namespaceObject } from "../
|
|
4
|
+
import { package_namespaceObject } from "../9958.js";
|
|
5
5
|
import { loadConfigFile, resolveDocRoot } from "../config/loadConfigFile.js";
|
|
6
6
|
import { dev } from "../node/dev.js";
|
|
7
7
|
import { build } from "../node/build.js";
|
|
@@ -17,11 +17,22 @@
|
|
|
17
17
|
z-index: 999;
|
|
18
18
|
background: var(--rp-banner-background);
|
|
19
19
|
height: 36px;
|
|
20
|
+
box-sizing: border-box;
|
|
21
|
+
padding: 0 3.5rem;
|
|
20
22
|
|
|
21
23
|
&__link {
|
|
24
|
+
display: block;
|
|
25
|
+
flex: 1 1 auto;
|
|
26
|
+
min-width: 0;
|
|
27
|
+
max-width: 100%;
|
|
28
|
+
overflow: hidden;
|
|
22
29
|
color: #fff;
|
|
23
30
|
font-weight: 700;
|
|
31
|
+
line-height: 36px;
|
|
32
|
+
text-align: center;
|
|
24
33
|
text-decoration: none;
|
|
34
|
+
text-overflow: ellipsis;
|
|
35
|
+
white-space: nowrap;
|
|
25
36
|
|
|
26
37
|
&:hover {
|
|
27
38
|
text-decoration: underline;
|
|
@@ -97,7 +97,11 @@ export const Banner = forwardRef<HTMLDivElement, BannerProps>(
|
|
|
97
97
|
<div className={clsx('rp-banner', className)} ref={ref}>
|
|
98
98
|
{customChildren ?? (
|
|
99
99
|
<>
|
|
100
|
-
<Link
|
|
100
|
+
<Link
|
|
101
|
+
href={href}
|
|
102
|
+
className="rp-banner__link"
|
|
103
|
+
title={typeof message === 'string' ? message : undefined}
|
|
104
|
+
>
|
|
101
105
|
{message}
|
|
102
106
|
</Link>
|
|
103
107
|
<SvgWrapper
|
|
@@ -259,11 +259,11 @@
|
|
|
259
259
|
color: var(--rp-c-text-code);
|
|
260
260
|
}
|
|
261
261
|
&:where(a > code) {
|
|
262
|
-
color: var(--rp-c-
|
|
262
|
+
color: var(--rp-c-link);
|
|
263
263
|
transition: color 0.25s;
|
|
264
264
|
}
|
|
265
265
|
&:where(a:hover > code) {
|
|
266
|
-
color: var(--rp-c-
|
|
266
|
+
color: var(--rp-c-link);
|
|
267
267
|
}
|
|
268
268
|
// #endregion
|
|
269
269
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
1
|
+
import { useEffect, useLayoutEffect, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
const useTopArrived = () => {
|
|
4
4
|
const [scrollY, setScrollY] = useState(0);
|
|
@@ -26,7 +26,7 @@ const useTopArrived = () => {
|
|
|
26
26
|
export const useNavTransparent = () => {
|
|
27
27
|
const { topArrived } = useTopArrived();
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
useLayoutEffect(() => {
|
|
30
30
|
if (topArrived) {
|
|
31
31
|
document.body.classList.remove('notTopArrived');
|
|
32
32
|
} else {
|
|
@@ -3,7 +3,7 @@ import './index.scss';
|
|
|
3
3
|
|
|
4
4
|
export function LastUpdated() {
|
|
5
5
|
const {
|
|
6
|
-
page: { lastUpdatedTime },
|
|
6
|
+
page: { lastUpdatedTime, lastUpdatedAuthor },
|
|
7
7
|
} = usePage();
|
|
8
8
|
const { site } = useSite();
|
|
9
9
|
const { themeConfig } = site;
|
|
@@ -11,7 +11,7 @@ export function LastUpdated() {
|
|
|
11
11
|
|
|
12
12
|
const t = useI18n();
|
|
13
13
|
|
|
14
|
-
if (!showLastUpdated) {
|
|
14
|
+
if (!showLastUpdated || !lastUpdatedTime) {
|
|
15
15
|
return null;
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -19,6 +19,12 @@ export function LastUpdated() {
|
|
|
19
19
|
<div className="rp-last-updated">
|
|
20
20
|
<p>
|
|
21
21
|
{t('lastUpdatedText')}: <span>{lastUpdatedTime}</span>
|
|
22
|
+
{lastUpdatedAuthor && (
|
|
23
|
+
<>
|
|
24
|
+
{' '}
|
|
25
|
+
{t('lastUpdatedAuthorText')} <span>{lastUpdatedAuthor}</span>
|
|
26
|
+
</>
|
|
27
|
+
)}
|
|
22
28
|
</p>
|
|
23
29
|
</div>
|
|
24
30
|
);
|
|
@@ -100,6 +100,9 @@ export const Link = forwardRef<HTMLAnchorElement, LinkProps>((props, ref) => {
|
|
|
100
100
|
onMouseEnter?.(event);
|
|
101
101
|
preloadLink(removeBaseHref);
|
|
102
102
|
}}
|
|
103
|
+
onTouchStart={() => {
|
|
104
|
+
preloadLink(removeBaseHref);
|
|
105
|
+
}}
|
|
103
106
|
onClick={e => {
|
|
104
107
|
onClick?.(e);
|
|
105
108
|
if (
|
|
@@ -134,6 +137,9 @@ export const Link = forwardRef<HTMLAnchorElement, LinkProps>((props, ref) => {
|
|
|
134
137
|
onMouseEnter?.(event);
|
|
135
138
|
preloadLink(removeBaseHref);
|
|
136
139
|
}}
|
|
140
|
+
onTouchStart={() => {
|
|
141
|
+
preloadLink(removeBaseHref);
|
|
142
|
+
}}
|
|
137
143
|
onClick={e => {
|
|
138
144
|
onClick?.(e);
|
|
139
145
|
if (
|
|
@@ -79,22 +79,26 @@ export function useLangsMenu() {
|
|
|
79
79
|
const translationMenuData = hasMultiLanguage
|
|
80
80
|
? {
|
|
81
81
|
items: localeLanguages.map(item => {
|
|
82
|
+
const isCurrentLang = item.lang === currentLang;
|
|
83
|
+
|
|
82
84
|
return {
|
|
83
85
|
text: item?.label,
|
|
84
|
-
link:
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
86
|
+
link: isCurrentLang
|
|
87
|
+
? ''
|
|
88
|
+
: replaceLang(
|
|
89
|
+
pathname + search,
|
|
90
|
+
{
|
|
91
|
+
current: currentLang,
|
|
92
|
+
target: item.lang,
|
|
93
|
+
default: defaultLang,
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
current: currentVersion,
|
|
97
|
+
default: defaultVersion,
|
|
98
|
+
},
|
|
99
|
+
cleanUrls,
|
|
100
|
+
pageType === '404',
|
|
101
|
+
),
|
|
98
102
|
lang: item.lang,
|
|
99
103
|
rel: 'alternate',
|
|
100
104
|
};
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
SocialLinks,
|
|
7
7
|
SwitchAppearance,
|
|
8
8
|
} from '@rspress/core/theme';
|
|
9
|
+
import { isDarkModeSwitchEnabled } from '@rspress/shared';
|
|
9
10
|
import './index.scss';
|
|
10
11
|
import { NavLangs, NavMenu, NavMenuDivider, NavVersions } from './NavMenu';
|
|
11
12
|
|
|
@@ -28,7 +29,9 @@ export function Nav(props: NavProps) {
|
|
|
28
29
|
} = props;
|
|
29
30
|
const navList = useNav();
|
|
30
31
|
const { site } = useSite();
|
|
31
|
-
const hasAppearanceSwitch =
|
|
32
|
+
const hasAppearanceSwitch = isDarkModeSwitchEnabled(
|
|
33
|
+
site.themeConfig.darkMode,
|
|
34
|
+
);
|
|
32
35
|
|
|
33
36
|
return (
|
|
34
37
|
<header className="rp-nav">
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { NoSSR, useI18n, useSite } from '@rspress/core/runtime';
|
|
2
2
|
import { SwitchAppearance } from '@rspress/core/theme';
|
|
3
|
+
import { isDarkModeSwitchEnabled } from '@rspress/shared';
|
|
3
4
|
import './NavScreenAppearance.scss';
|
|
4
5
|
|
|
5
6
|
export function NavScreenAppearance() {
|
|
6
7
|
const { site } = useSite();
|
|
7
|
-
const hasAppearanceSwitch =
|
|
8
|
+
const hasAppearanceSwitch = isDarkModeSwitchEnabled(
|
|
9
|
+
site.themeConfig.darkMode,
|
|
10
|
+
);
|
|
8
11
|
const t = useI18n();
|
|
9
12
|
return (
|
|
10
13
|
<>
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { NoSSR, useSite } from '@rspress/core/runtime';
|
|
2
2
|
import { SocialLinks, SwitchAppearance } from '@rspress/core/theme';
|
|
3
|
+
import { isDarkModeSwitchEnabled } from '@rspress/shared';
|
|
3
4
|
import './index.scss';
|
|
4
5
|
import { NavScreenLangs } from './NavScreenLangs';
|
|
5
6
|
import { NavScreenVersions } from './NavScreenVersions';
|
|
6
7
|
|
|
7
8
|
export function NavScreenMenuOthers() {
|
|
8
9
|
const { site } = useSite();
|
|
9
|
-
const hasAppearanceSwitch =
|
|
10
|
+
const hasAppearanceSwitch = isDarkModeSwitchEnabled(
|
|
11
|
+
site.themeConfig.darkMode,
|
|
12
|
+
);
|
|
10
13
|
const socialLinks = site?.themeConfig?.socialLinks || [];
|
|
11
14
|
const hasSocialLinks = socialLinks.length > 0;
|
|
12
15
|
return (
|
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
LlmsOpenRow,
|
|
6
6
|
ReadPercent,
|
|
7
7
|
Toc,
|
|
8
|
-
useDynamicToc,
|
|
9
8
|
} from '@rspress/core/theme';
|
|
10
9
|
import './index.scss';
|
|
11
10
|
import { ScrollToTop } from './ScrollToTop';
|
|
@@ -13,17 +12,12 @@ import { ScrollToTop } from './ScrollToTop';
|
|
|
13
12
|
export function Outline() {
|
|
14
13
|
const t = useI18n();
|
|
15
14
|
|
|
16
|
-
const headers = useDynamicToc();
|
|
17
15
|
const {
|
|
18
16
|
site: {
|
|
19
17
|
themeConfig: { enableScrollToTop = true, llmsUI },
|
|
20
18
|
},
|
|
21
19
|
} = useSite();
|
|
22
20
|
|
|
23
|
-
if (headers.length === 0) {
|
|
24
|
-
return <></>;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
21
|
const placement =
|
|
28
22
|
typeof llmsUI === 'object' ? (llmsUI?.placement ?? 'title') : 'title';
|
|
29
23
|
|
|
@@ -51,6 +51,22 @@ const useDebounce = <T extends (...args: any[]) => any>(cb: T) => {
|
|
|
51
51
|
return debounced;
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
+
const normalizeSuggestions = (
|
|
55
|
+
suggestions: DefaultMatchResult['result'],
|
|
56
|
+
): Map<string, DefaultMatchResultItem[]> => {
|
|
57
|
+
return suggestions.reduce(
|
|
58
|
+
(groups, item) => {
|
|
59
|
+
const group = item.title;
|
|
60
|
+
if (!groups.has(group)) {
|
|
61
|
+
groups.set(group, []);
|
|
62
|
+
}
|
|
63
|
+
groups.get(group)!.push(item);
|
|
64
|
+
return groups;
|
|
65
|
+
},
|
|
66
|
+
new Map() as Map<string, DefaultMatchResult['result']>,
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
54
70
|
export function SearchPanel({ focused, setFocused }: SearchPanelProps) {
|
|
55
71
|
const [query, setQuery] = useState('');
|
|
56
72
|
const [searchResult, setSearchResult] = useState<MatchResult>([]);
|
|
@@ -277,12 +293,18 @@ export function SearchPanel({ focused, setFocused }: SearchPanelProps) {
|
|
|
277
293
|
|
|
278
294
|
// Prefetch the search index when the page is idle
|
|
279
295
|
useEffect(() => {
|
|
296
|
+
let idleCallbackID: number | undefined;
|
|
280
297
|
if ('requestIdleCallback' in window && !pageSearcherRef.current) {
|
|
281
|
-
window.requestIdleCallback(() => {
|
|
298
|
+
idleCallbackID = window.requestIdleCallback(() => {
|
|
282
299
|
const searcher = createSearcher();
|
|
283
300
|
searcher.fetchSearchIndex();
|
|
284
301
|
});
|
|
285
302
|
}
|
|
303
|
+
return () => {
|
|
304
|
+
if (idleCallbackID !== undefined && 'cancelIdleCallback' in window) {
|
|
305
|
+
window.cancelIdleCallback(idleCallbackID);
|
|
306
|
+
}
|
|
307
|
+
};
|
|
286
308
|
}, []);
|
|
287
309
|
|
|
288
310
|
// init pageSearcher again when lang or version changed
|
|
@@ -358,22 +380,6 @@ export function SearchPanel({ focused, setFocused }: SearchPanelProps) {
|
|
|
358
380
|
|
|
359
381
|
const handleQueryChange = useDebounce(handleQueryChangedImpl);
|
|
360
382
|
|
|
361
|
-
const normalizeSuggestions = (
|
|
362
|
-
suggestions: DefaultMatchResult['result'],
|
|
363
|
-
): Map<string, DefaultMatchResultItem[]> => {
|
|
364
|
-
return suggestions.reduce(
|
|
365
|
-
(groups, item) => {
|
|
366
|
-
const group = item.title;
|
|
367
|
-
if (!groups.has(group)) {
|
|
368
|
-
groups.set(group, []);
|
|
369
|
-
}
|
|
370
|
-
groups.get(group)!.push(item);
|
|
371
|
-
return groups;
|
|
372
|
-
},
|
|
373
|
-
new Map() as Map<string, DefaultMatchResult['result']>,
|
|
374
|
-
);
|
|
375
|
-
};
|
|
376
|
-
|
|
377
383
|
const renderSearchResult = (result: MatchResult, isSearching: boolean) => {
|
|
378
384
|
if (result.length === 1) {
|
|
379
385
|
const currentSearchResult = result[0]
|
|
@@ -511,6 +517,7 @@ export function SearchPanel({ focused, setFocused }: SearchPanelProps) {
|
|
|
511
517
|
aria-label="SearchPanelInput"
|
|
512
518
|
autoComplete="off"
|
|
513
519
|
autoFocus
|
|
520
|
+
inputMode="search"
|
|
514
521
|
onChange={e => handleQueryChange(e.target.value)}
|
|
515
522
|
/>
|
|
516
523
|
<label>
|
|
@@ -213,24 +213,23 @@ export class PageSearcher {
|
|
|
213
213
|
highlightStartIndex + THRESHOLD_CONTENT_LENGTH,
|
|
214
214
|
);
|
|
215
215
|
const statement = content.slice(statementStartIndex, statementEndIndex);
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
)
|
|
225
|
-
.map(match => {
|
|
216
|
+
|
|
217
|
+
const highlightInfoList: Array<{ start: number; length: number }> = [];
|
|
218
|
+
const limitIndex = highlightStartIndex + THRESHOLD_CONTENT_LENGTH;
|
|
219
|
+
for (const match of (item as RemotePageInfo)._matchesPosition?.content ||
|
|
220
|
+
[]) {
|
|
221
|
+
const { start, length } = match;
|
|
222
|
+
|
|
223
|
+
if (start >= highlightStartIndex && start + length <= limitIndex) {
|
|
226
224
|
const startCharIndex =
|
|
227
|
-
byteToCharIndex(content,
|
|
228
|
-
|
|
229
|
-
|
|
225
|
+
byteToCharIndex(content, start) - statementStartIndex + 3; // prefix `...` length is 3
|
|
226
|
+
|
|
227
|
+
highlightInfoList.push({
|
|
230
228
|
start: startCharIndex,
|
|
231
|
-
length
|
|
232
|
-
};
|
|
233
|
-
}
|
|
229
|
+
length,
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
}
|
|
234
233
|
|
|
235
234
|
matchedResult.push({
|
|
236
235
|
type: 'content',
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
useActiveAnchor,
|
|
9
9
|
useDynamicToc,
|
|
10
10
|
} from '@rspress/core/theme';
|
|
11
|
-
import { forwardRef, useEffect, useRef } from 'react';
|
|
11
|
+
import { forwardRef, type ReactNode, useEffect, useRef } from 'react';
|
|
12
12
|
import { createPortal } from 'react-dom';
|
|
13
13
|
import './index.scss';
|
|
14
14
|
|
|
@@ -20,11 +20,15 @@ export const SidebarMenu = forwardRef(
|
|
|
20
20
|
onIsSidebarOpenChange,
|
|
21
21
|
isOutlineOpen,
|
|
22
22
|
onIsOutlineOpenChange,
|
|
23
|
+
beforeOutline,
|
|
24
|
+
afterOutline,
|
|
23
25
|
}: {
|
|
24
26
|
isSidebarOpen: boolean;
|
|
25
27
|
onIsSidebarOpenChange: (isOpen: boolean) => void;
|
|
26
28
|
isOutlineOpen: boolean;
|
|
27
29
|
onIsOutlineOpenChange: (isOpen: boolean) => void;
|
|
30
|
+
beforeOutline?: ReactNode;
|
|
31
|
+
afterOutline?: ReactNode;
|
|
28
32
|
},
|
|
29
33
|
forwardedRef,
|
|
30
34
|
) => {
|
|
@@ -36,6 +40,9 @@ export const SidebarMenu = forwardRef(
|
|
|
36
40
|
const headers = useDynamicToc();
|
|
37
41
|
const { scrolledHeader } = useActiveAnchor(headers);
|
|
38
42
|
|
|
43
|
+
const outlineDisabled =
|
|
44
|
+
!beforeOutline && !afterOutline && headers.length === 0;
|
|
45
|
+
|
|
39
46
|
const {
|
|
40
47
|
frontmatter: {
|
|
41
48
|
sidebar: sidebarConfig = true,
|
|
@@ -98,7 +105,7 @@ export const SidebarMenu = forwardRef(
|
|
|
98
105
|
{showOutline ? (
|
|
99
106
|
<button
|
|
100
107
|
type="button"
|
|
101
|
-
disabled={
|
|
108
|
+
disabled={outlineDisabled}
|
|
102
109
|
onClick={e => {
|
|
103
110
|
e.preventDefault();
|
|
104
111
|
e.stopPropagation();
|
|
@@ -118,7 +125,7 @@ export const SidebarMenu = forwardRef(
|
|
|
118
125
|
)}
|
|
119
126
|
<ReadPercent size={14} strokeWidth={2} />
|
|
120
127
|
{/* TODO: discussion */}
|
|
121
|
-
{
|
|
128
|
+
{!outlineDisabled && (
|
|
122
129
|
<SvgWrapper
|
|
123
130
|
icon={IconArrowRight}
|
|
124
131
|
className="rp-sidebar-menu__right__icon"
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { clearAllBodyScrollLocks, disableBodyScroll } from 'body-scroll-lock';
|
|
2
|
-
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { type ReactNode, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import { SidebarMenu } from '.';
|
|
4
4
|
import { useClickOutside } from './useClickOutside';
|
|
5
5
|
|
|
6
|
-
function useSidebarMenu() {
|
|
6
|
+
function useSidebarMenu(beforeOutline?: ReactNode, afterOutline?: ReactNode) {
|
|
7
7
|
const [isSidebarOpen, setIsSidebarOpen] = useState(false);
|
|
8
8
|
const [isOutlineOpen, setIsOutlineOpen] = useState(false);
|
|
9
9
|
|
|
@@ -39,9 +39,18 @@ function useSidebarMenu() {
|
|
|
39
39
|
isOutlineOpen={isOutlineOpen}
|
|
40
40
|
onIsOutlineOpenChange={setIsOutlineOpen}
|
|
41
41
|
ref={sidebarMenuRef}
|
|
42
|
+
beforeOutline={beforeOutline}
|
|
43
|
+
afterOutline={afterOutline}
|
|
42
44
|
/>
|
|
43
45
|
);
|
|
44
|
-
}, [
|
|
46
|
+
}, [
|
|
47
|
+
isOutlineOpen,
|
|
48
|
+
isSidebarOpen,
|
|
49
|
+
setIsOutlineOpen,
|
|
50
|
+
setIsSidebarOpen,
|
|
51
|
+
beforeOutline,
|
|
52
|
+
afterOutline,
|
|
53
|
+
]);
|
|
45
54
|
|
|
46
55
|
return {
|
|
47
56
|
sidebarMenu,
|