@rspress/core 2.0.14 → 2.0.16

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.
Files changed (184) hide show
  1. package/dist/0~execa.js +1 -1
  2. package/dist/3358.js +1 -1
  3. package/dist/5580.js +1 -1
  4. package/dist/{4942.js → 6010.js} +1 -1
  5. package/dist/8005.js +1 -1
  6. package/dist/{7261.js → 9958.js} +2 -1
  7. package/dist/cli/index.js +6 -6
  8. package/dist/eject-theme/components/Callout/index.scss +32 -0
  9. package/dist/eject-theme/components/Callout/index.tsx +9 -1
  10. package/dist/eject-theme/components/DocContent/doc.scss +2 -2
  11. package/dist/eject-theme/components/HomeBackground/useNavTransparent.tsx +2 -2
  12. package/dist/eject-theme/components/HoverGroup/index.scss +1 -1
  13. package/dist/eject-theme/components/LastUpdated/index.tsx +8 -2
  14. package/dist/eject-theme/components/Link/useLinkNavigate.ts +1 -1
  15. package/dist/eject-theme/components/Llms/LlmsContainer.tsx +1 -1
  16. package/dist/eject-theme/components/Nav/NavMenu.scss +1 -1
  17. package/dist/eject-theme/components/Nav/hooks.tsx +18 -14
  18. package/dist/eject-theme/components/Nav/index.tsx +4 -1
  19. package/dist/eject-theme/components/NavScreen/NavScreenAppearance.tsx +4 -1
  20. package/dist/eject-theme/components/NavScreen/NavScreenMenuItem.scss +3 -0
  21. package/dist/eject-theme/components/NavScreen/NavScreenMenuOthers.tsx +4 -1
  22. package/dist/eject-theme/components/Overview/index.tsx +1 -2
  23. package/dist/eject-theme/components/Overview/utils.ts +4 -10
  24. package/dist/eject-theme/components/Search/SearchPanel.tsx +23 -17
  25. package/dist/eject-theme/components/Search/logic/providers/LocalProvider.ts +3 -1
  26. package/dist/eject-theme/components/SidebarMenu/useClickOutside.ts +1 -2
  27. package/dist/index.d.ts +1 -1
  28. package/dist/node/PluginDriver.js +4 -4
  29. package/dist/node/auto-nav-sidebar/index.js +1 -1
  30. package/dist/node/auto-nav-sidebar/locales.js +1 -1
  31. package/dist/node/auto-nav-sidebar/normalize.js +1 -1
  32. package/dist/node/auto-nav-sidebar/utils.js +1 -1
  33. package/dist/node/auto-nav-sidebar/walk.d.ts +4 -2
  34. package/dist/node/auto-nav-sidebar/walk.js +3 -3
  35. package/dist/node/constants.d.ts +2 -1
  36. package/dist/node/constants.js +12 -6
  37. package/dist/node/initRsbuild.js +8 -15
  38. package/dist/node/last-updated/index.d.ts +3 -3
  39. package/dist/node/last-updated/index.js +24 -9
  40. package/dist/node/mdx/options.js +8 -1
  41. package/dist/node/mdx/processor.js +3 -1
  42. package/dist/node/mdx/rehypePlugins/headerAnchor.d.ts +1 -1
  43. package/dist/node/mdx/rehypePlugins/headerAnchor.js +10 -6
  44. package/dist/node/mdx/remarkPlugins/containerSyntax.d.ts +2 -1
  45. package/dist/node/mdx/remarkPlugins/containerSyntax.js +13 -6
  46. package/dist/node/mdx/remarkPlugins/link.js +91 -16
  47. package/dist/node/mdx/remarkPlugins/toc.d.ts +8 -1
  48. package/dist/node/mdx/remarkPlugins/toc.js +44 -15
  49. package/dist/node/route/RoutePage.js +1 -1
  50. package/dist/node/route/RouteService.d.ts +6 -0
  51. package/dist/node/route/RouteService.js +41 -7
  52. package/dist/node/route/extractPageData.js +1 -1
  53. package/dist/node/route/normalizeRoutePath.js +1 -1
  54. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.d.ts +7 -0
  55. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.js +7 -0
  56. package/dist/node/runtimeModule/i18n.js +1 -1
  57. package/dist/node/runtimeModule/pageData/createPageData.js +2 -1
  58. package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
  59. package/dist/node/runtimeModule/searchHooks.js +1 -1
  60. package/dist/node/runtimeModule/siteData/createSiteData.js +1 -1
  61. package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +12 -2
  62. package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +1 -1
  63. package/dist/node/serve.js +1 -1
  64. package/dist/node/ssg/htmlFile.js +1 -1
  65. package/dist/node/ssg/renderPage.js +1 -1
  66. package/dist/node/ssg/renderPageWorker.js +1 -1
  67. package/dist/node/ssg/renderPages.js +2 -2
  68. package/dist/node/ssg/rsbuildPluginCSR.js +2 -1
  69. package/dist/node/ssg/rsbuildPluginSSG.js +5 -3
  70. package/dist/node/ssg/ssgEnv.js +1 -1
  71. package/dist/node/ssg-md/llms/emitLlmsTxt.js +1 -1
  72. package/dist/node/ssg-md/llms/llmsTxt.js +1 -1
  73. package/dist/node/ssg-md/renderPage.js +1 -1
  74. package/dist/node/ssg-md/renderPages.js +2 -2
  75. package/dist/node/ssg-md/rsbuildPluginSSGMD.js +3 -2
  76. package/dist/node/utils/checkLanguageParity.js +1 -1
  77. package/dist/node/utils/createHash.js +1 -1
  78. package/dist/node/utils/flattenMdxContent.js +1 -1
  79. package/dist/node/utils/getPageKey.js +1 -1
  80. package/dist/node/utils/reactAlias.js +1 -1
  81. package/dist/runtime/App.d.ts +2 -1
  82. package/dist/runtime/App.js +1 -1
  83. package/dist/runtime/ClientApp.d.ts +1 -1
  84. package/dist/runtime/ClientApp.js +2 -1
  85. package/dist/runtime/Content.d.ts +1 -1
  86. package/dist/runtime/NoSSR.d.ts +1 -1
  87. package/dist/theme/components/Badge/index.d.ts +1 -1
  88. package/dist/theme/components/Callout/index.css +29 -0
  89. package/dist/theme/components/Callout/index.d.ts +1 -1
  90. package/dist/theme/components/CodeBlock/index.d.ts +1 -1
  91. package/dist/theme/components/CodeButtonGroup/CopyCodeButton.d.ts +1 -1
  92. package/dist/theme/components/CodeButtonGroup/index.d.ts +1 -1
  93. package/dist/theme/components/DocContent/doc.css +2 -2
  94. package/dist/theme/components/DocContent/docComponents/a.d.ts +1 -1
  95. package/dist/theme/components/DocContent/docComponents/code.d.ts +1 -1
  96. package/dist/theme/components/DocContent/docComponents/hr.d.ts +1 -1
  97. package/dist/theme/components/DocContent/docComponents/img.d.ts +1 -1
  98. package/dist/theme/components/DocContent/docComponents/index.d.ts +18 -18
  99. package/dist/theme/components/DocContent/docComponents/list.d.ts +3 -3
  100. package/dist/theme/components/DocContent/docComponents/paragraph.d.ts +3 -3
  101. package/dist/theme/components/DocContent/docComponents/pre.d.ts +1 -1
  102. package/dist/theme/components/DocContent/docComponents/table.d.ts +3 -3
  103. package/dist/theme/components/DocContent/docComponents/title.d.ts +6 -6
  104. package/dist/theme/components/DocContent/index.d.ts +1 -1
  105. package/dist/theme/components/DocFooter/index.d.ts +1 -1
  106. package/dist/theme/components/EditLink/index.d.ts +1 -1
  107. package/dist/theme/components/FallbackHeading/index.d.ts +1 -1
  108. package/dist/theme/components/HomeBackground/index.d.ts +1 -1
  109. package/dist/theme/components/HomeBackground/useNavTransparent.d.ts +1 -1
  110. package/dist/theme/components/HomeBackground/useNavTransparent.js +2 -2
  111. package/dist/theme/components/HomeFeature/useCardAnimation.d.ts +1 -1
  112. package/dist/theme/components/HomeFooter/index.d.ts +1 -1
  113. package/dist/theme/components/HomeHero/index.d.ts +1 -1
  114. package/dist/theme/components/HoverGroup/index.css +1 -1
  115. package/dist/theme/components/HoverGroup/index.d.ts +1 -1
  116. package/dist/theme/components/HoverGroup/useHoverGroup.d.ts +1 -1
  117. package/dist/theme/components/LastUpdated/index.d.ts +1 -1
  118. package/dist/theme/components/LastUpdated/index.js +13 -3
  119. package/dist/theme/components/Link/useLinkNavigate.js +1 -1
  120. package/dist/theme/components/Llms/LlmsContainer.d.ts +2 -3
  121. package/dist/theme/components/Llms/LlmsCopyButton.d.ts +1 -1
  122. package/dist/theme/components/Llms/LlmsCopyRow.d.ts +1 -1
  123. package/dist/theme/components/Llms/LlmsOpenRow.d.ts +1 -1
  124. package/dist/theme/components/Llms/LlmsViewOptions.d.ts +1 -1
  125. package/dist/theme/components/Nav/NavMenu.css +1 -1
  126. package/dist/theme/components/Nav/NavMenu.d.ts +9 -9
  127. package/dist/theme/components/Nav/hooks.js +6 -3
  128. package/dist/theme/components/Nav/index.d.ts +1 -1
  129. package/dist/theme/components/Nav/index.js +2 -1
  130. package/dist/theme/components/NavHamburger/index.d.ts +1 -1
  131. package/dist/theme/components/NavScreen/NavScreenAppearance.d.ts +1 -1
  132. package/dist/theme/components/NavScreen/NavScreenAppearance.js +2 -1
  133. package/dist/theme/components/NavScreen/NavScreenLangs.d.ts +1 -1
  134. package/dist/theme/components/NavScreen/NavScreenMenu.d.ts +1 -1
  135. package/dist/theme/components/NavScreen/NavScreenMenuItem.css +10 -1
  136. package/dist/theme/components/NavScreen/NavScreenMenuItem.d.ts +5 -5
  137. package/dist/theme/components/NavScreen/NavScreenMenuOthers.d.ts +1 -1
  138. package/dist/theme/components/NavScreen/NavScreenMenuOthers.js +2 -1
  139. package/dist/theme/components/NavScreen/NavScreenVersions.d.ts +1 -1
  140. package/dist/theme/components/NavScreen/index.d.ts +2 -2
  141. package/dist/theme/components/NavTitle/index.d.ts +1 -1
  142. package/dist/theme/components/Outline/ScrollToTop.d.ts +1 -1
  143. package/dist/theme/components/Outline/index.d.ts +1 -1
  144. package/dist/theme/components/Overview/index.d.ts +1 -1
  145. package/dist/theme/components/OverviewGroup/index.d.ts +1 -1
  146. package/dist/theme/components/PackageManagerTabs/icons/Bun.d.ts +1 -1
  147. package/dist/theme/components/PackageManagerTabs/icons/Deno.d.ts +1 -1
  148. package/dist/theme/components/PackageManagerTabs/icons/Npm.d.ts +1 -1
  149. package/dist/theme/components/PackageManagerTabs/icons/Pnpm.d.ts +1 -1
  150. package/dist/theme/components/PackageManagerTabs/icons/Yarn.d.ts +1 -1
  151. package/dist/theme/components/PackageManagerTabs/index.d.ts +1 -1
  152. package/dist/theme/components/PrevNextPage/index.d.ts +1 -1
  153. package/dist/theme/components/Prompt/index.d.ts +1 -1
  154. package/dist/theme/components/ReadPercent/index.d.ts +1 -1
  155. package/dist/theme/components/Root/index.d.ts +1 -1
  156. package/dist/theme/components/Search/NoSearchResult.d.ts +1 -1
  157. package/dist/theme/components/Search/SearchButton.d.ts +1 -1
  158. package/dist/theme/components/Search/SearchPanel.d.ts +1 -1
  159. package/dist/theme/components/Search/SearchPanel.js +11 -7
  160. package/dist/theme/components/Search/SuggestItem.d.ts +1 -1
  161. package/dist/theme/components/Search/index.d.ts +1 -1
  162. package/dist/theme/components/Sidebar/SidebarDivider.d.ts +1 -1
  163. package/dist/theme/components/Sidebar/SidebarGroup.d.ts +1 -1
  164. package/dist/theme/components/Sidebar/SidebarItem.d.ts +2 -2
  165. package/dist/theme/components/Sidebar/SidebarSectionHeader.d.ts +1 -1
  166. package/dist/theme/components/Sidebar/index.d.ts +2 -2
  167. package/dist/theme/components/SidebarMenu/useSidebarMenu.d.ts +1 -1
  168. package/dist/theme/components/SocialLinks/GithubStars.d.ts +1 -1
  169. package/dist/theme/components/SocialLinks/SocialLink.d.ts +1 -1
  170. package/dist/theme/components/SocialLinks/index.d.ts +1 -1
  171. package/dist/theme/components/SourceCode/index.d.ts +1 -1
  172. package/dist/theme/components/Steps/index.d.ts +1 -1
  173. package/dist/theme/components/SvgWrapper/index.d.ts +1 -1
  174. package/dist/theme/components/SwitchAppearance/index.d.ts +1 -1
  175. package/dist/theme/components/Tag/index.d.ts +1 -1
  176. package/dist/theme/components/Toc/TocItem.d.ts +1 -1
  177. package/dist/theme/components/Toc/index.d.ts +1 -1
  178. package/dist/theme/layout/DocLayout/index.d.ts +1 -1
  179. package/dist/theme/layout/HomeLayout/index.d.ts +1 -1
  180. package/dist/theme/layout/Layout/index.d.ts +1 -1
  181. package/dist/theme/layout/NotFountLayout/index.d.ts +1 -1
  182. package/dist/theme/logic/useThemeState.d.ts +6 -7
  183. package/dist/theme/logic/useThemeState.js +19 -15
  184. package/package.json +19 -19
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 "./4942.js";
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/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 "./4942.js";
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({
@@ -2439,7 +2439,7 @@ const pluginVirtualModule = (pluginOptions = {})=>({
2439
2439
  });
2440
2440
  export { DEFAULT_PAGE_EXTENSIONS } from "@rspress/shared/constants";
2441
2441
  export { default as promises, mkdir, readdir as promises_readdir, rm, stat as promises_stat, writeFile } from "node:fs/promises";
2442
- export { MDX_OR_MD_REGEXP, RSPRESS_TEMP_DIR, SEARCH_INDEX_NAME, addLeadingSlash, addTrailingSlash, getSidebarDataGroup, isDebugMode, isExternalUrl, isProduction, 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";
2443
2443
  export { logger } from "@rspress/shared/logger";
2444
2444
  export { extractTextAndId, getIconUrlPath, loadFrontMatter } from "@rspress/shared/node-utils";
2445
2445
  export { createRequire as external_node_module_createRequire } from "node:module";
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";
@@ -1,5 +1,5 @@
1
1
  var package_namespaceObject = {
2
- rE: "2.0.14"
2
+ rE: "2.0.16"
3
3
  };
4
4
  async function pMap(iterable, mapper, { concurrency = 1 / 0, stopOnError = true, signal } = {}) {
5
5
  return new Promise((resolve_, reject_)=>{
@@ -92,6 +92,7 @@ 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
97
  export { default as node_path, isAbsolute, relative, resolve as external_node_path_resolve } from "node:path";
97
98
  export { pathToFileURL } from "node:url";
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 "../7261.js";
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";
@@ -20,8 +20,8 @@ logger.greet(landingMessage);
20
20
  const setNodeEnv = (env)=>{
21
21
  process.env.NODE_ENV = env;
22
22
  };
23
- cli.option('-c,--config [config]', 'Specify the path to the config file');
24
- cli.command('[root]', 'start dev server').alias('dev').option('--port [port]', 'port number').option('--host [host]', 'hostname').option('--base <base>', 'deployment base path').action(async (root, options)=>{
23
+ cli.option('-c, --config <config>', 'Set the configuration file (relative or absolute path)');
24
+ cli.command('[root]', 'Start the dev server').alias('dev').option('--port <port>', 'Set the port number for the server').option('--host [host]', 'Set the host that the server listens to').option('--base <base>', 'Set the base path and override config.base').action(async (root, options)=>{
25
25
  setNodeEnv('development');
26
26
  let isRestarting = false;
27
27
  const cwd = process.cwd();
@@ -83,7 +83,7 @@ cli.command('[root]', 'start dev server').alias('dev').option('--port [port]', '
83
83
  process.on('SIGINT', exitProcess);
84
84
  process.on('SIGTERM', exitProcess);
85
85
  });
86
- cli.command('build [root]').option('--base <base>', 'deployment base path').action(async (root, options)=>{
86
+ cli.command('build [root]', 'Build the documentation site for production').option('--base <base>', 'Set the base path and override config.base').action(async (root, options)=>{
87
87
  setNodeEnv('production');
88
88
  const cwd = process.cwd();
89
89
  const { config, configFilePath } = await loadConfigFile(options.config);
@@ -101,7 +101,7 @@ cli.command('build [root]').option('--base <base>', 'deployment base path').acti
101
101
  process.exit(1);
102
102
  }
103
103
  });
104
- cli.command('preview [root]').alias('serve').option('--port [port]', 'port number').option('--host [host]', 'hostname').option('--base <base>', 'deployment base path').action(async (root, options)=>{
104
+ cli.command('preview [root]', 'Preview the production build locally').alias('serve').option('--port <port>', 'Set the port number for the server').option('--host [host]', 'Set the host that the server listens to').option('--base <base>', 'Set the base path and override config.base').action(async (root, options)=>{
105
105
  setNodeEnv('production');
106
106
  const cwd = process.cwd();
107
107
  const { port, host } = options || {};
@@ -115,7 +115,7 @@ cli.command('preview [root]').alias('serve').option('--port [port]', 'port numbe
115
115
  configFilePath
116
116
  });
117
117
  });
118
- cli.command('eject [component]', 'Eject a theme component to customize it').action(async (component)=>{
118
+ cli.command('eject [component]', 'Eject a theme component for customization').action(async (component)=>{
119
119
  if (!component) return void await listComponents();
120
120
  const cwd = process.cwd();
121
121
  try {
@@ -18,6 +18,11 @@
18
18
  --rp-container-info-bg: rgba(0, 149, 255, 0.06);
19
19
  --rp-container-info-code-bg: rgba(0, 149, 255, 0.1);
20
20
 
21
+ --rp-container-important-border: rgba(137, 87, 229, 0.3);
22
+ --rp-container-important-text: #8250df;
23
+ --rp-container-important-bg: rgba(137, 87, 229, 0.08);
24
+ --rp-container-important-code-bg: rgba(137, 87, 229, 0.1);
25
+
21
26
  --rp-container-warning-border: rgba(255, 197, 23, 0.4);
22
27
  --rp-container-warning-text: #887233;
23
28
  --rp-container-warning-bg: rgba(255, 197, 23, 0.1);
@@ -52,6 +57,10 @@
52
57
  --rp-container-info-text: #66c2ff;
53
58
  --rp-container-info-bg: rgba(0, 149, 255, 0.1);
54
59
 
60
+ --rp-container-important-text: #b083f0;
61
+ --rp-container-important-border: rgba(137, 87, 229, 0.35);
62
+ --rp-container-important-bg: rgba(137, 87, 229, 0.12);
63
+
55
64
  --rp-container-warning-text: rgb(251, 180, 81);
56
65
  --rp-container-warning-border: rgba(255, 197, 23, 0.25);
57
66
  --rp-container-warning-bg: rgba(255, 197, 23, 0.12);
@@ -176,6 +185,29 @@
176
185
  }
177
186
  }
178
187
 
188
+ // important
189
+ .rp-callout--important {
190
+ border-color: var(--rp-container-important-border);
191
+ background-color: var(--rp-container-important-bg);
192
+
193
+ .rp-callout__title {
194
+ color: var(--rp-container-important-text);
195
+ &::before {
196
+ background-color: var(--rp-container-important-text);
197
+ }
198
+ }
199
+
200
+ // inline code
201
+ :not(pre) > code {
202
+ color: var(--rp-container-important-text);
203
+ background-color: var(--rp-container-important-code-bg);
204
+ }
205
+
206
+ a {
207
+ color: var(--rp-container-important-text);
208
+ }
209
+ }
210
+
179
211
  // warning
180
212
  .rp-callout--warning {
181
213
  border-color: var(--rp-container-warning-border);
@@ -2,7 +2,15 @@ import type { ReactNode } from 'react';
2
2
  import './index.scss';
3
3
 
4
4
  export interface CalloutProps {
5
- type: 'tip' | 'note' | 'warning' | 'caution' | 'danger' | 'info' | 'details';
5
+ type:
6
+ | 'tip'
7
+ | 'note'
8
+ | 'important'
9
+ | 'warning'
10
+ | 'caution'
11
+ | 'danger'
12
+ | 'info'
13
+ | 'details';
6
14
  title?: string;
7
15
  children: ReactNode;
8
16
  }
@@ -259,11 +259,11 @@
259
259
  color: var(--rp-c-text-code);
260
260
  }
261
261
  &:where(a > code) {
262
- color: var(--rp-c-brand-dark);
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-brand);
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
- useEffect(() => {
29
+ useLayoutEffect(() => {
30
30
  if (topArrived) {
31
31
  document.body.classList.remove('notTopArrived');
32
32
  } else {
@@ -69,7 +69,7 @@
69
69
  &__link {
70
70
  display: flex;
71
71
  align-items: center;
72
- gap: 2px;
72
+ gap: 4px;
73
73
  // For click area
74
74
  height: 100%;
75
75
  }
@@ -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
  );
@@ -99,7 +99,7 @@ export function useLinkNavigate(
99
99
  return;
100
100
  }
101
101
  }
102
- navigate(removeBaseHref, { replace: false });
102
+ await navigate(removeBaseHref, { replace: false });
103
103
  };
104
104
 
105
105
  if (startTransition) {
@@ -1,7 +1,7 @@
1
1
  import type React from 'react';
2
2
  import './LlmsContainer.scss';
3
3
 
4
- export interface LlmsContainerProps extends React.HTMLAttributes<HTMLDivElement> {}
4
+ export type LlmsContainerProps = React.HTMLAttributes<HTMLDivElement>;
5
5
 
6
6
  export function LlmsContainer(props: LlmsContainerProps) {
7
7
  return <div {...props} className={'rp-not-doc rp-llms-container'} />;
@@ -25,7 +25,7 @@
25
25
  justify-content: center;
26
26
  align-items: center;
27
27
  height: 100%;
28
- gap: 2px;
28
+ gap: 4px;
29
29
 
30
30
  // text
31
31
  text-align: center;
@@ -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: replaceLang(
85
- pathname + search,
86
- {
87
- current: currentLang,
88
- target: item.lang,
89
- default: defaultLang,
90
- },
91
- {
92
- current: currentVersion,
93
- default: defaultVersion,
94
- },
95
- cleanUrls,
96
- pageType === '404',
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 = site.themeConfig.darkMode !== false;
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 = site.themeConfig.darkMode !== false;
8
+ const hasAppearanceSwitch = isDarkModeSwitchEnabled(
9
+ site.themeConfig.darkMode,
10
+ );
8
11
  const t = useI18n();
9
12
  return (
10
13
  <>
@@ -22,6 +22,9 @@
22
22
  }
23
23
 
24
24
  &__left {
25
+ display: inline-flex;
26
+ align-items: center;
27
+ gap: 4px;
25
28
  font-size: 14px;
26
29
  font-weight: 500;
27
30
  line-height: 22px;
@@ -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 = site.themeConfig.darkMode !== false;
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 (
@@ -109,8 +109,7 @@ export function Overview(props: {
109
109
  const { pages } = siteData;
110
110
  const overviewModules = pages.filter(page => subFilter(page.routePath));
111
111
  let overviewSidebarGroups = useSidebar() as (
112
- | NormalizedSidebarGroup
113
- | SidebarItem
112
+ NormalizedSidebarGroup | SidebarItem
114
113
  )[];
115
114
 
116
115
  if (overviewSidebarGroups[0]?.link !== routePath) {
@@ -17,10 +17,7 @@ function removeIndex(link: string) {
17
17
  */
18
18
  export function findItemByRoutePath(
19
19
  items: (
20
- | SidebarItem
21
- | NormalizedSidebarGroup
22
- | SidebarDivider
23
- | SidebarSectionHeader
20
+ SidebarItem | NormalizedSidebarGroup | SidebarDivider | SidebarSectionHeader
24
21
  )[],
25
22
  routePath: string,
26
23
  ): (SidebarItem | NormalizedSidebarGroup)[] {
@@ -61,8 +58,7 @@ export function findItemByRoutePath(
61
58
  }
62
59
 
63
60
  const matchRoutePathItem = items[matchRoutePathItemIndex] as
64
- | SidebarItem
65
- | NormalizedSidebarGroup;
61
+ SidebarItem | NormalizedSidebarGroup;
66
62
 
67
63
  const isArray = (i: unknown): i is Array<unknown> =>
68
64
  Array.isArray(i) && i.length >= 1;
@@ -75,8 +71,7 @@ export function findItemByRoutePath(
75
71
  }
76
72
 
77
73
  return matchRoutePathItem.items.filter(item => !isSidebarDivider(item)) as (
78
- | SidebarItem
79
- | NormalizedSidebarGroup
74
+ SidebarItem | NormalizedSidebarGroup
80
75
  )[];
81
76
  }
82
77
 
@@ -86,8 +81,7 @@ export function findItemByRoutePath(
86
81
  result.splice(matchRoutePathItemIndex, 1);
87
82
  }
88
83
  const res = result.filter(item => !isSidebarDivider(item)) as (
89
- | SidebarItem
90
- | NormalizedSidebarGroup
84
+ SidebarItem | NormalizedSidebarGroup
91
85
  )[];
92
86
 
93
87
  return res;
@@ -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]
@@ -29,7 +29,9 @@ interface PageIndexForFlexSearch extends PageIndexInfo {
29
29
  // Create a type that satisfies DocumentData constraints by mapping all properties
30
30
  // to DocumentValue | DocumentValue[] while preserving the original structure
31
31
  type FlexSearchCompatibleData = {
32
- [K in keyof PageIndexForFlexSearch]: PageIndexForFlexSearch[K] extends DocumentValue
32
+ [
33
+ K in keyof PageIndexForFlexSearch
34
+ ]: PageIndexForFlexSearch[K] extends DocumentValue
33
35
  ? PageIndexForFlexSearch[K]
34
36
  : DocumentValue;
35
37
  } & {
@@ -2,8 +2,7 @@ import { useEffect } from 'react';
2
2
 
3
3
  function useClickOutside(
4
4
  ref:
5
- | React.RefObject<HTMLElement | null>
6
- | React.RefObject<HTMLElement | null>[],
5
+ React.RefObject<HTMLElement | null> | React.RefObject<HTMLElement | null>[],
7
6
  handler: (event: MouseEvent | TouchEvent) => void,
8
7
  ) {
9
8
  useEffect(() => {
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type { EditLink, Feature, FrontMatterMeta, Header, Hero, I18nText, LocalSearchOptions, Nav, NavItem, NavItemWithChildren, NavItemWithLink, NavItemWithLinkAndChildren, NormalizedSidebarGroup, PageIndexInfo, RemotePageInfo, RouteMeta, RspressPlugin, Sidebar, SidebarData, SidebarDivider, SidebarGroup, SidebarItem, SidebarSectionHeader, SocialLink, UserConfig, } from '@rspress/shared';
1
+ export type { DarkMode, EditLink, Feature, FrontMatterMeta, Header, Hero, I18nText, LocalSearchOptions, Nav, NavItem, NavItemWithChildren, NavItemWithLink, NavItemWithLinkAndChildren, NormalizedSidebarGroup, PageIndexInfo, RemotePageInfo, RouteMeta, RspressPlugin, Sidebar, SidebarData, SidebarDivider, SidebarGroup, SidebarItem, SidebarSectionHeader, SocialLink, UserConfig, } from '@rspress/shared';
2
2
  export { getSidebarDataGroup, normalizeHref, normalizePosixPath, RSPRESS_TEMP_DIR, removeTrailingSlash, withBase, } from '@rspress/shared';
3
3
  export { logger } from '@rspress/shared/logger';
4
4
  export { getIconUrlPath, getNodeAttribute, mergeDocConfig, } from '@rspress/shared/node-utils';
@@ -1,4 +1,4 @@
1
- import { addTrailingSlash, node_path, addLeadingSlash } from "../4942.js";
1
+ import { addTrailingSlash, node_path, addLeadingSlash } from "../6010.js";
2
2
  import { createError } from "./utils/error.js";
3
3
  import { haveNavSidebarConfig as auto_nav_sidebar_haveNavSidebarConfig } from "./auto-nav-sidebar/index.js";
4
4
  class PluginDriver {
@@ -25,11 +25,11 @@ class PluginDriver {
25
25
  this.clearPlugins();
26
26
  const config = this.#config;
27
27
  const themeConfig = config?.themeConfig || {};
28
- const enableLastUpdated = themeConfig?.lastUpdated;
28
+ const lastUpdatedConfig = themeConfig?.lastUpdated;
29
29
  const mediumZoomConfig = config?.mediumZoom ?? true;
30
- if (enableLastUpdated) {
30
+ if (lastUpdatedConfig) {
31
31
  const { pluginLastUpdated } = await import("./last-updated/index.js");
32
- this.addPlugin(pluginLastUpdated());
32
+ this.addPlugin(pluginLastUpdated('object' == typeof lastUpdatedConfig ? lastUpdatedConfig.author : false));
33
33
  }
34
34
  if (mediumZoomConfig) {
35
35
  const { pluginMediumZoom } = await import("./medium-zoom/index.js");
@@ -1,4 +1,4 @@
1
- import { DEFAULT_PAGE_EXTENSIONS, node_path } from "../../4942.js";
1
+ import { DEFAULT_PAGE_EXTENSIONS, node_path } from "../../6010.js";
2
2
  import { processLocales, combineWalkResult } from "./locales.js";
3
3
  import { walk } from "./walk.js";
4
4
  async function runAutoNavSide(config, metaFileSet, mdFileSet) {
@@ -1,4 +1,4 @@
1
- import { node_path } from "../../4942.js";
1
+ import { node_path } from "../../6010.js";
2
2
  import { walk } from "./walk.js";
3
3
  function combineWalkResult(walks, versions) {
4
4
  return walks.reduce((acc, cur, curIndex)=>({
@@ -1,6 +1,6 @@
1
1
  import { __webpack_require__ } from "../../0~rslib-runtime.js";
2
2
  import "../../7986.js";
3
- import { extname, logger, promises_readdir, external_node_path_relative, isExternalUrl, slash, promises_stat, join } from "../../4942.js";
3
+ import { extname, logger, promises_readdir, external_node_path_relative, isExternalUrl, slash, promises_stat, join } from "../../6010.js";
4
4
  import { createError } from "../utils/error.js";
5
5
  import { pathExists, extractInfoFromFrontmatterWithAbsolutePath, readJson } from "./utils.js";
6
6
  import { absolutePathToRoutePath, addRoutePrefix } from "../route/RoutePage.js";
@@ -1,4 +1,4 @@
1
- import { node_path, extractTextAndId, promises, loadFrontMatter } from "../../4942.js";
1
+ import { node_path, extractTextAndId, promises, loadFrontMatter } from "../../6010.js";
2
2
  import { createError } from "../utils/error.js";
3
3
  async function pathExists(path) {
4
4
  try {
@@ -1,5 +1,7 @@
1
- import { type NavItem, type Sidebar } from '@rspress/shared';
1
+ import { type NavItem } from '@rspress/shared';
2
2
  export declare function walk(workDir: string, docsDir: string, extensions: string[], metaFileSet: Set<string>, mdFileSet: Set<string>): Promise<{
3
3
  nav: NavItem[];
4
- sidebar: Sidebar;
4
+ sidebar: {
5
+ [x: string]: (import("@rspress/shared").SidebarDivider | import("@rspress/shared").SidebarGroup | import("@rspress/shared").SidebarItem | import("@rspress/shared").SidebarSectionHeader)[];
6
+ };
5
7
  }>;
@@ -1,4 +1,4 @@
1
- import { isExternalUrl, node_path, promises } from "../../4942.js";
1
+ import { isExternalUrl, node_path, promises } from "../../6010.js";
2
2
  import { pathExists } from "../utils/fs.js";
3
3
  import { readJson } from "./utils.js";
4
4
  import { addRoutePrefix } from "../route/RoutePage.js";
@@ -34,7 +34,7 @@ async function walk(workDir, docsDir, extensions, metaFileSet, mdFileSet) {
34
34
  return {
35
35
  nav: navConfig,
36
36
  sidebar: {
37
- '/': await scanSideMeta(workDir, docsDir, extensions, metaFileSet, mdFileSet)
37
+ [addRoutePrefix(workDir, docsDir, '/')]: await scanSideMeta(workDir, docsDir, extensions, metaFileSet, mdFileSet)
38
38
  }
39
39
  };
40
40
  }
@@ -57,7 +57,7 @@ async function walk(workDir, docsDir, extensions, metaFileSet, mdFileSet) {
57
57
  return {
58
58
  nav: [],
59
59
  sidebar: {
60
- '/': await scanSideMeta(workDir, docsDir, extensions, metaFileSet, mdFileSet)
60
+ [addRoutePrefix(workDir, docsDir, '/')]: await scanSideMeta(workDir, docsDir, extensions, metaFileSet, mdFileSet)
61
61
  }
62
62
  };
63
63
  }
@@ -1,7 +1,8 @@
1
+ import { type DarkMode } from '@rspress/shared';
1
2
  export declare const RSPRESS_VERSION: string;
2
3
  export declare const isProduction: () => boolean;
3
4
  export declare const importStatementRegex: RegExp;
4
- export declare const inlineThemeScript: string;
5
+ export declare const getInlineThemeScript: (darkMode: DarkMode | undefined) => string;
5
6
  export declare const PACKAGE_ROOT: string;
6
7
  export declare const DEFAULT_THEME: string;
7
8
  export declare const EJECTED_THEME: string;