@rspress/core 2.0.0-rc.0 → 2.0.0-rc.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.
Files changed (298) hide show
  1. package/bin/rspress.js +1 -1
  2. package/dist/0~7675.989ee664.js +1791 -0
  3. package/dist/1218.3869bad6.js +2 -0
  4. package/dist/4669.12208c6a.js +2 -0
  5. package/dist/5313.6594aba0.js +63 -0
  6. package/dist/5485.2a0273cf.js +98 -0
  7. package/dist/6289.c67fe0d5.js +5 -0
  8. package/dist/7805.cadab34e.js +4 -0
  9. package/dist/8813.9da1f210.js +2 -0
  10. package/dist/cli/config/index.js +4 -0
  11. package/dist/cli/config/loadConfigFile.js +30 -0
  12. package/dist/cli/index.cb89dbd1.js +3 -0
  13. package/dist/cli/index.js +122 -0
  14. package/dist/eject-theme/components/Banner/index.tsx +3 -4
  15. package/dist/eject-theme/components/Button/index.scss +1 -6
  16. package/dist/eject-theme/components/Callout/index.scss +0 -2
  17. package/dist/eject-theme/components/CodeBlock/index.scss +4 -12
  18. package/dist/eject-theme/components/CodeBlock/index.tsx +6 -1
  19. package/dist/eject-theme/components/CodeButtonGroup/CopyCodeButton.tsx +1 -3
  20. package/dist/eject-theme/components/CodeButtonGroup/index.scss +5 -1
  21. package/dist/eject-theme/components/CodeButtonGroup/index.tsx +1 -3
  22. package/dist/eject-theme/components/DocContent/doc.scss +30 -9
  23. package/dist/eject-theme/components/DocContent/docComponents/table.tsx +10 -4
  24. package/dist/eject-theme/components/DocContent/index.tsx +5 -2
  25. package/dist/eject-theme/components/{DocContent/FallbackHeading.tsx → FallbackHeading/index.tsx} +20 -11
  26. package/dist/eject-theme/components/HoverGroup/index.scss +5 -1
  27. package/dist/eject-theme/components/HoverGroup/index.tsx +5 -1
  28. package/dist/eject-theme/components/Link/index.tsx +43 -9
  29. package/dist/eject-theme/components/Link/useLinkNavigate.ts +32 -16
  30. package/dist/eject-theme/components/Nav/NavMenu.scss +1 -0
  31. package/dist/eject-theme/components/Nav/NavMenu.tsx +2 -3
  32. package/dist/eject-theme/components/Nav/NavTitle.scss +11 -0
  33. package/dist/eject-theme/components/Nav/NavTitle.tsx +1 -0
  34. package/dist/eject-theme/components/Nav/index.scss +0 -8
  35. package/dist/eject-theme/components/NavHamburger/index.tsx +3 -4
  36. package/dist/eject-theme/components/NavScreen/NavScreenMenuItem.scss +14 -0
  37. package/dist/eject-theme/components/NavScreen/NavScreenMenuItem.tsx +2 -3
  38. package/dist/eject-theme/components/Outline/index.scss +0 -1
  39. package/dist/eject-theme/components/Overview/OverviewGroup.tsx +1 -2
  40. package/dist/eject-theme/components/Overview/index.tsx +6 -2
  41. package/dist/eject-theme/components/PackageManagerTabs/index.tsx +12 -0
  42. package/dist/eject-theme/components/PrevNextPage/index.tsx +6 -3
  43. package/dist/eject-theme/components/Root/index.tsx +58 -0
  44. package/dist/eject-theme/components/Search/NoSearchResult.tsx +2 -3
  45. package/dist/eject-theme/components/Search/SearchButton.tsx +3 -4
  46. package/dist/eject-theme/components/Search/SearchPanel.tsx +14 -9
  47. package/dist/eject-theme/components/Search/SuggestItem.tsx +15 -12
  48. package/dist/eject-theme/components/Sidebar/SidebarGroup.tsx +2 -3
  49. package/dist/eject-theme/components/Sidebar/SidebarItem.scss +12 -8
  50. package/dist/eject-theme/components/Sidebar/SidebarItem.tsx +6 -4
  51. package/dist/eject-theme/components/Sidebar/SidebarSectionHeader.scss +1 -1
  52. package/dist/eject-theme/components/SidebarMenu/index.tsx +4 -4
  53. package/dist/eject-theme/components/SocialLinks/index.tsx +2 -3
  54. package/dist/eject-theme/components/SourceCode/index.scss +2 -1
  55. package/dist/eject-theme/components/SourceCode/index.tsx +6 -4
  56. package/dist/eject-theme/components/SwitchAppearance/index.tsx +3 -5
  57. package/dist/eject-theme/components/Tabs/index.scss +19 -22
  58. package/dist/eject-theme/components/Toc/TocItem.scss +8 -4
  59. package/dist/eject-theme/components/Toc/TocItem.tsx +1 -0
  60. package/dist/index.d.ts +6 -6
  61. package/dist/index.js +16 -3134
  62. package/dist/node/PluginDriver.d.ts +1 -1
  63. package/dist/node/PluginDriver.js +143 -0
  64. package/dist/node/auto-nav-sidebar/index.js +44 -0
  65. package/dist/node/auto-nav-sidebar/locales.js +26 -0
  66. package/dist/node/auto-nav-sidebar/normalize.js +228 -0
  67. package/dist/node/auto-nav-sidebar/utils.js +68 -0
  68. package/dist/node/auto-nav-sidebar/walk.js +67 -0
  69. package/dist/node/build.js +31 -0
  70. package/dist/node/constants.d.ts +1 -0
  71. package/dist/node/constants.js +33 -0
  72. package/dist/node/dev.js +32 -0
  73. package/dist/node/eject.js +111 -0
  74. package/dist/node/index.d.ts +5 -5
  75. package/dist/node/initRsbuild.d.ts +2 -2
  76. package/dist/node/initRsbuild.js +338 -0
  77. package/dist/node/last-updated/index.js +28 -0
  78. package/dist/node/logger/hint.d.ts +1 -1
  79. package/dist/node/logger/hint.js +85 -0
  80. package/dist/node/mdx/loader.d.ts +1 -1
  81. package/dist/node/mdx/loader.e1578c62.js +13 -0
  82. package/dist/{loader.js → node/mdx/loader.js} +2 -2
  83. package/dist/node/mdx/options.d.ts +2 -2
  84. package/dist/node/mdx/options.js +100 -0
  85. package/dist/node/mdx/processor.d.ts +2 -2
  86. package/dist/node/mdx/processor.js +71 -0
  87. package/dist/node/mdx/rehypePlugins/codeMeta.js +10 -0
  88. package/dist/node/mdx/rehypePlugins/headerAnchor.js +53 -0
  89. package/dist/node/mdx/rehypePlugins/shiki.js +34 -0
  90. package/dist/node/mdx/rehypePlugins/transformers/add-lang.js +15 -0
  91. package/dist/node/mdx/rehypePlugins/transformers/add-line-numbers.js +22 -0
  92. package/dist/node/mdx/rehypePlugins/transformers/add-title.js +24 -0
  93. package/dist/node/mdx/rehypePlugins/transformers/add-wrap-code.js +22 -0
  94. package/dist/node/mdx/rehypePlugins/transformers/index.d.ts +5 -5
  95. package/dist/node/mdx/rehypePlugins/transformers/index.js +5 -0
  96. package/dist/node/mdx/rehypePlugins/transformers/meta-highlight.js +41 -0
  97. package/dist/node/mdx/remarkPlugins/builtin.js +11 -0
  98. package/dist/node/mdx/remarkPlugins/containerSyntax.js +190 -0
  99. package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +66 -0
  100. package/dist/node/mdx/remarkPlugins/image.js +67 -0
  101. package/dist/node/mdx/remarkPlugins/link.d.ts +1 -1
  102. package/dist/node/mdx/remarkPlugins/link.js +99 -0
  103. package/dist/node/mdx/remarkPlugins/toc.js +50 -0
  104. package/dist/node/mdx/types.d.ts +3 -3
  105. package/dist/node/medium-zoom/index.d.ts +1 -1
  106. package/dist/node/medium-zoom/index.js +14 -0
  107. package/dist/node/route/RoutePage.d.ts +1 -1
  108. package/dist/node/route/RoutePage.js +61 -0
  109. package/dist/node/route/RouteService.d.ts +1 -1
  110. package/dist/node/route/RouteService.js +177 -0
  111. package/dist/node/route/extractPageData.d.ts +1 -1
  112. package/dist/node/route/extractPageData.js +112 -0
  113. package/dist/node/route/normalizeRoutePath.js +54 -0
  114. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.d.ts +21 -0
  115. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.js +150 -0
  116. package/dist/node/runtimeModule/globalStyles.d.ts +1 -1
  117. package/dist/node/runtimeModule/globalStyles.js +12 -0
  118. package/dist/node/runtimeModule/globalUIComponents.d.ts +1 -1
  119. package/dist/node/runtimeModule/globalUIComponents.js +25 -0
  120. package/dist/node/runtimeModule/i18n.d.ts +2 -2
  121. package/dist/node/runtimeModule/i18n.js +83 -0
  122. package/dist/node/runtimeModule/pageData/createPageData.d.ts +1 -1
  123. package/dist/node/runtimeModule/pageData/createPageData.js +64 -0
  124. package/dist/node/runtimeModule/pageData/rsbuildPlugin.d.ts +1 -1
  125. package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +51 -0
  126. package/dist/node/runtimeModule/routeList.d.ts +1 -1
  127. package/dist/node/runtimeModule/routeList.js +7 -0
  128. package/dist/node/runtimeModule/searchHooks.d.ts +1 -1
  129. package/dist/node/runtimeModule/searchHooks.js +11 -0
  130. package/dist/node/runtimeModule/siteData/createSiteData.js +34 -0
  131. package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +94 -0
  132. package/dist/node/runtimeModule/siteData/rsbuildPlugin.d.ts +1 -1
  133. package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +24 -0
  134. package/dist/node/runtimeModule/socialLinks.d.ts +1 -1
  135. package/dist/node/runtimeModule/socialLinks.js +8 -0
  136. package/dist/node/runtimeModule/types.d.ts +2 -2
  137. package/dist/node/serve.js +23 -0
  138. package/dist/node/ssg/renderHtmlTemplate.js +33 -0
  139. package/dist/node/ssg/renderPage.js +34 -0
  140. package/dist/node/ssg/renderPageWorker.474f9f73.js +2 -0
  141. package/dist/node/ssg/renderPageWorker.js +15 -0
  142. package/dist/node/ssg/renderPages.d.ts +1 -1
  143. package/dist/node/ssg/renderPages.js +105 -0
  144. package/dist/node/ssg/renderPages.js.LICENSE.txt +4 -0
  145. package/dist/node/ssg/rsbuildPluginCSR.d.ts +1 -1
  146. package/dist/node/ssg/rsbuildPluginCSR.js +27 -0
  147. package/dist/node/ssg/rsbuildPluginSSG.d.ts +1 -1
  148. package/dist/node/ssg/rsbuildPluginSSG.js +72 -0
  149. package/dist/node/ssg/ssgEnv.js +33 -0
  150. package/dist/node/ssg/ssgEnv.js.LICENSE.txt +5 -0
  151. package/dist/node/ssg-md/llms/emitLlmsTxt.d.ts +1 -1
  152. package/dist/node/ssg-md/llms/emitLlmsTxt.js +80 -0
  153. package/dist/node/ssg-md/llms/llmsTxt.d.ts +1 -1
  154. package/dist/node/ssg-md/llms/llmsTxt.js +66 -0
  155. package/dist/node/ssg-md/react/index.d.ts +1 -1
  156. package/dist/node/ssg-md/remarkSplitMdx.js +202 -0
  157. package/dist/node/ssg-md/renderPage.js +31 -0
  158. package/dist/node/ssg-md/renderPages.d.ts +1 -1
  159. package/dist/node/ssg-md/renderPages.js +27 -0
  160. package/dist/node/ssg-md/rsbuildPluginSSGMD.d.ts +1 -1
  161. package/dist/node/ssg-md/rsbuildPluginSSGMD.js +47 -0
  162. package/dist/node/utils/applyReplaceRules.js +6 -0
  163. package/dist/node/utils/checkLanguageParity.js +77 -0
  164. package/dist/node/utils/createHash.js +5 -0
  165. package/dist/node/utils/error.d.ts +9 -0
  166. package/dist/node/utils/error.js +9 -0
  167. package/dist/node/utils/escapeHeadingIds.js +5 -0
  168. package/dist/node/utils/flattenMdxContent.js +74 -0
  169. package/dist/node/utils/fs.js +14 -0
  170. package/dist/node/utils/getImportAstNode.js +63 -0
  171. package/dist/node/utils/getPageKey.js +6 -0
  172. package/dist/node/utils/getSocialIcons.js +32 -0
  173. package/dist/node/utils/index.d.ts +10 -9
  174. package/dist/node/utils/normalizePath.js +10 -0
  175. package/dist/node/utils/reactAlias.d.ts +2 -0
  176. package/dist/node/utils/reactAlias.js +83 -0
  177. package/dist/rslib-runtime.99091bf6.js +18 -0
  178. package/dist/runtime/App.js +2 -2
  179. package/dist/runtime/ClientApp.d.ts +1 -1
  180. package/dist/runtime/ClientApp.js +0 -4
  181. package/dist/runtime/ssrMdServerEntry.js +1 -1
  182. package/dist/runtime/ssrServerEntry.js +2 -1
  183. package/dist/runtime.72d450ac.js +1 -0
  184. package/dist/runtime.js +3 -2
  185. package/dist/shiki-transformers.d.ts +1 -1
  186. package/dist/shiki-transformers.js +6 -120
  187. package/dist/theme/assets/moon.js +9 -26
  188. package/dist/theme/components/Banner/index.d.ts +1 -1
  189. package/dist/theme/components/Banner/index.js +2 -3
  190. package/dist/theme/components/Button/index.css +1 -1
  191. package/dist/theme/components/Callout/index.css +0 -2
  192. package/dist/theme/components/CodeBlock/index.css +4 -15
  193. package/dist/theme/components/CodeBlock/index.js +1 -0
  194. package/dist/theme/components/CodeButtonGroup/CopyCodeButton.js +3 -5
  195. package/dist/theme/components/CodeButtonGroup/index.css +5 -1
  196. package/dist/theme/components/CodeButtonGroup/index.js +3 -5
  197. package/dist/theme/components/DocContent/doc.css +30 -8
  198. package/dist/theme/components/DocContent/docComponents/index.d.ts +3 -3
  199. package/dist/theme/components/DocContent/docComponents/table.d.ts +2 -2
  200. package/dist/theme/components/DocContent/docComponents/table.js +8 -3
  201. package/dist/theme/components/DocContent/index.js +3 -2
  202. package/dist/theme/components/{DocContent/FallbackHeading.js → FallbackHeading/index.js} +19 -11
  203. package/dist/theme/components/HoverGroup/index.css +5 -1
  204. package/dist/theme/components/HoverGroup/index.js +1 -0
  205. package/dist/theme/components/HoverGroup/useHoverGroup.d.ts +1 -1
  206. package/dist/theme/components/Link/index.d.ts +18 -1
  207. package/dist/theme/components/Link/index.js +14 -8
  208. package/dist/theme/components/Link/useLinkNavigate.d.ts +4 -1
  209. package/dist/theme/components/Link/useLinkNavigate.js +23 -17
  210. package/dist/theme/components/Nav/NavMenu.css +1 -0
  211. package/dist/theme/components/Nav/NavMenu.js +2 -3
  212. package/dist/theme/components/Nav/NavTitle.css +12 -0
  213. package/dist/theme/components/Nav/NavTitle.d.ts +1 -0
  214. package/dist/theme/components/Nav/NavTitle.js +1 -0
  215. package/dist/theme/components/Nav/index.css +0 -8
  216. package/dist/theme/components/NavHamburger/index.js +3 -4
  217. package/dist/theme/components/NavScreen/NavScreenMenuItem.css +9 -0
  218. package/dist/theme/components/NavScreen/NavScreenMenuItem.js +2 -3
  219. package/dist/theme/components/Outline/index.css +0 -1
  220. package/dist/theme/components/Overview/OverviewGroup.js +1 -2
  221. package/dist/theme/components/Overview/index.js +1 -2
  222. package/dist/theme/components/PackageManagerTabs/index.d.ts +1 -1
  223. package/dist/theme/components/PackageManagerTabs/index.js +4 -0
  224. package/dist/theme/components/PrevNextPage/index.js +3 -4
  225. package/dist/theme/components/Root/index.d.ts +54 -0
  226. package/dist/theme/components/Root/index.js +7 -0
  227. package/dist/theme/components/Search/NoSearchResult.js +2 -3
  228. package/dist/theme/components/Search/SearchButton.js +3 -4
  229. package/dist/theme/components/Search/SearchPanel.js +13 -16
  230. package/dist/theme/components/Search/SuggestItem.d.ts +1 -1
  231. package/dist/theme/components/Search/SuggestItem.js +7 -11
  232. package/dist/theme/components/Search/logic/Provider.d.ts +1 -1
  233. package/dist/theme/components/Search/logic/providers/LocalProvider.d.ts +2 -2
  234. package/dist/theme/components/Search/logic/search.d.ts +1 -1
  235. package/dist/theme/components/Sidebar/SidebarGroup.js +2 -3
  236. package/dist/theme/components/Sidebar/SidebarItem.css +11 -3
  237. package/dist/theme/components/Sidebar/SidebarItem.js +6 -3
  238. package/dist/theme/components/Sidebar/SidebarSectionHeader.css +1 -1
  239. package/dist/theme/components/SidebarMenu/index.js +3 -5
  240. package/dist/theme/components/SocialLinks/index.js +2 -3
  241. package/dist/theme/components/SourceCode/index.css +5 -0
  242. package/dist/theme/components/SourceCode/index.js +2 -4
  243. package/dist/theme/components/SwitchAppearance/index.js +3 -5
  244. package/dist/theme/components/Tabs/index.css +13 -22
  245. package/dist/theme/components/Toc/TocItem.css +7 -4
  246. package/dist/theme/components/Toc/TocItem.js +1 -0
  247. package/dist/theme/icons.d.ts +25 -0
  248. package/dist/theme/icons.js +47 -0
  249. package/dist/theme/index.d.ts +62 -59
  250. package/dist/theme/index.js +5 -2
  251. package/dist/theme/layout/DocLayout/index.css +2 -2
  252. package/dist/theme/layout/DocLayout/index.js +1 -4
  253. package/dist/theme/layout/Layout/index.d.ts +1 -1
  254. package/dist/theme/layout/Layout/index.js +3 -3
  255. package/dist/theme/logic/useFullTextSearch.d.ts +1 -1
  256. package/dist/theme/logic/useScrollAfterNav.d.ts +5 -0
  257. package/dist/theme/logic/{sideEffects.js → useScrollAfterNav.js} +5 -6
  258. package/dist/theme/logic/useScrollReset.d.ts +5 -0
  259. package/dist/theme/logic/useScrollReset.js +12 -0
  260. package/dist/theme/logic/useSetup.js +2 -0
  261. package/dist/theme/styles/base.css +1 -10
  262. package/dist/theme/styles/index.d.ts +1 -1
  263. package/dist/theme/styles/index.js +1 -1
  264. package/dist/theme/styles/scrollbar.css +1 -0
  265. package/dist/theme/styles/vars/base-vars.css +5 -3
  266. package/dist/theme/styles/vars/home-vars.css +4 -2
  267. package/package.json +19 -20
  268. package/dist/3~101.js +0 -1786
  269. package/dist/3~335.js +0 -26
  270. package/dist/3~395.js +0 -74
  271. package/dist/cli.js +0 -259
  272. package/dist/index.js.LICENSE.txt +0 -10
  273. package/dist/node/auto-nav-sidebar/fixtures/docs/guide/c.d.ts +0 -2
  274. package/dist/node/auto-nav-sidebar/fixtures/docs-locales/en/guide/c.d.ts +0 -2
  275. package/dist/node/auto-nav-sidebar/fixtures/docs-locales/zh/guide/c.d.ts +0 -2
  276. package/dist/node/auto-nav-sidebar/locales.test.d.ts +0 -1
  277. package/dist/node/auto-nav-sidebar/walk.test.d.ts +0 -1
  278. package/dist/node/mdx/rehypePlugins/headerAnchor.test.d.ts +0 -1
  279. package/dist/node/mdx/remarkPlugins/containerSyntax.test.d.ts +0 -1
  280. package/dist/node/mdx/remarkPlugins/fileCodeBlock.test.d.ts +0 -1
  281. package/dist/node/mdx/remarkPlugins/image.test.d.ts +0 -1
  282. package/dist/node/mdx/remarkPlugins/link.test.d.ts +0 -1
  283. package/dist/node/route/RouteService.test.d.ts +0 -1
  284. package/dist/node/route/extractPageData.test.d.ts +0 -1
  285. package/dist/node/route/fixtures/basic/guide/c.d.ts +0 -2
  286. package/dist/node/route/normalizeRoutePath.test.d.ts +0 -1
  287. package/dist/node/runtimeModule/i18n.test.d.ts +0 -1
  288. package/dist/node/ssg-md/remarkSplitMdx.test.d.ts +0 -4
  289. package/dist/node/utils/checkLanguageParity.test.d.ts +0 -1
  290. package/dist/node/utils/detectCustomIcon.d.ts +0 -1
  291. package/dist/node/utils/detectReactVersion.d.ts +0 -3
  292. package/dist/processor.js +0 -4539
  293. package/dist/renderPageWorker.js +0 -196
  294. package/dist/theme/components/Search/logic/util.test.d.ts +0 -1
  295. /package/dist/cli/{config.d.ts → config/index.d.ts} +0 -0
  296. /package/dist/{shiki-transformers.js.LICENSE.txt → node/mdx/rehypePlugins/transformers/meta-highlight.js.LICENSE.txt} +0 -0
  297. /package/dist/theme/components/{DocContent/FallbackHeading.d.ts → FallbackHeading/index.d.ts} +0 -0
  298. /package/dist/theme/logic/{sideEffects.d.ts → useSetup.d.ts} +0 -0
@@ -63,7 +63,11 @@
63
63
  font-weight: 500;
64
64
  line-height: 32px;
65
65
 
66
- cursor: pointer;
66
+ &__link {
67
+ // For click area
68
+ display: block;
69
+ height: 100%;
70
+ }
67
71
 
68
72
  &--active {
69
73
  font-weight: 600;
@@ -45,7 +45,11 @@ function HoverGroup({
45
45
  'rp-hover-group__item--active': isActiveItem,
46
46
  })}
47
47
  >
48
- <Link href={link} aria-label={text}>
48
+ <Link
49
+ href={link}
50
+ aria-label={text}
51
+ className="rp-hover-group__item__link"
52
+ >
49
53
  {text}
50
54
  </Link>
51
55
  </li>
@@ -1,10 +1,10 @@
1
1
  import { preloadLink } from '@rspress/core/runtime';
2
+ import clsx from 'clsx';
2
3
  import nprogress from 'nprogress';
3
4
  import type React from 'react';
4
- import type { ComponentProps } from 'react';
5
- import { getHref, useLinkNavigate } from './useLinkNavigate';
5
+ import type { ComponentProps, TransitionStartFunction } from 'react';
6
6
  import './index.scss';
7
- import clsx from 'clsx';
7
+ import { getHref, useLinkNavigate } from './useLinkNavigate';
8
8
 
9
9
  export interface LinkProps extends ComponentProps<'a'> {
10
10
  href?: string;
@@ -13,6 +13,24 @@ export interface LinkProps extends ComponentProps<'a'> {
13
13
  onMouseEnter?: (
14
14
  event: React.MouseEvent<HTMLAnchorElement, MouseEvent>,
15
15
  ) => void;
16
+
17
+ /**
18
+ * Get isPending state of Link navigation
19
+ *
20
+ * ```tsx
21
+ * const [isPending, startTransition] = useTransition();
22
+ * <Link
23
+ * href="/some-path"
24
+ * startTransition={startTransition}
25
+ * >
26
+ * Some Link
27
+ * </Link>
28
+ * ```
29
+ *
30
+ * @private
31
+ * @unstable
32
+ */
33
+ startTransition?: TransitionStartFunction;
16
34
  }
17
35
 
18
36
  nprogress.configure({ showSpinner: false });
@@ -26,19 +44,29 @@ nprogress.configure({ showSpinner: false });
26
44
  * 4. Link is styled.
27
45
  */
28
46
  export function Link(props: LinkProps) {
29
- const { href = '/', children, className = '', onClick, onMouseEnter } = props;
47
+ const {
48
+ href = '/',
49
+ children,
50
+ className = '',
51
+ onClick,
52
+ onMouseEnter,
53
+ startTransition,
54
+ ...otherProps
55
+ } = props;
30
56
 
31
57
  const { linkType, removeBaseHref, withBaseHref } = getHref(href);
32
- const navigate = useLinkNavigate();
58
+ const navigate = useLinkNavigate({ startTransition });
33
59
 
34
60
  if (linkType === 'external') {
35
61
  return (
36
62
  <a
37
- {...props}
38
63
  href={href}
39
64
  target="_blank"
40
65
  rel="noopener noreferrer"
41
66
  className={clsx(className, 'rp-link')}
67
+ onClick={onClick}
68
+ onMouseEnter={onMouseEnter}
69
+ {...otherProps}
42
70
  >
43
71
  {children}
44
72
  </a>
@@ -47,7 +75,13 @@ export function Link(props: LinkProps) {
47
75
 
48
76
  if (linkType === 'hashOnly') {
49
77
  return (
50
- <a {...props} href={href} className={clsx(className, 'rp-link')}>
78
+ <a
79
+ href={href}
80
+ className={clsx(className, 'rp-link')}
81
+ onClick={onClick}
82
+ onMouseEnter={onMouseEnter}
83
+ {...otherProps}
84
+ >
51
85
  {children}
52
86
  </a>
53
87
  );
@@ -56,7 +90,6 @@ export function Link(props: LinkProps) {
56
90
  if (linkType === 'relative') {
57
91
  return (
58
92
  <a
59
- {...props}
60
93
  href={href}
61
94
  className={clsx(className, 'rp-link')}
62
95
  onMouseEnter={event => {
@@ -81,6 +114,7 @@ export function Link(props: LinkProps) {
81
114
  e.preventDefault();
82
115
  navigate(href);
83
116
  }}
117
+ {...otherProps}
84
118
  >
85
119
  {children}
86
120
  </a>
@@ -89,7 +123,6 @@ export function Link(props: LinkProps) {
89
123
 
90
124
  return (
91
125
  <a
92
- {...props}
93
126
  href={withBaseHref}
94
127
  className={clsx(className, 'rp-link')}
95
128
  onMouseEnter={event => {
@@ -114,6 +147,7 @@ export function Link(props: LinkProps) {
114
147
  e.preventDefault();
115
148
  navigate(removeBaseHref);
116
149
  }}
150
+ {...otherProps}
117
151
  >
118
152
  {children}
119
153
  </a>
@@ -9,7 +9,11 @@ import {
9
9
  withBase,
10
10
  } from '@rspress/core/runtime';
11
11
  import nprogress from 'nprogress';
12
- import { useCallback } from 'react';
12
+ import {
13
+ startTransition as reactStartTransition,
14
+ type TransitionStartFunction,
15
+ useCallback,
16
+ } from 'react';
13
17
 
14
18
  nprogress.configure({ showSpinner: false });
15
19
 
@@ -60,7 +64,11 @@ export function getHref(href: string): {
60
64
  * For import { Link } from '@theme';
61
65
  * useNavigate with preload logic
62
66
  */
63
- export function useLinkNavigate(): (href: string) => Promise<void> {
67
+ export function useLinkNavigate(
68
+ { startTransition }: { startTransition?: TransitionStartFunction } = {
69
+ startTransition: reactStartTransition,
70
+ },
71
+ ): (href: string) => Promise<void> {
64
72
  const { pathname: currPagePathname } = useLocation();
65
73
  const navigate = useNavigateInner();
66
74
 
@@ -72,22 +80,30 @@ export function useLinkNavigate(): (href: string) => Promise<void> {
72
80
  return;
73
81
  }
74
82
 
75
- const inCurrPage = isActive(removeBaseHref, currPagePathname);
76
- if (!process.env.__SSR__ && !inCurrPage) {
77
- const matchedRoute = pathnameToRouteService(removeBaseHref);
78
- if (matchedRoute) {
79
- const timer = setTimeout(() => {
80
- nprogress.start();
81
- }, 200);
82
- await matchedRoute.preload();
83
- clearTimeout(timer);
84
- nprogress.done();
85
- } else {
86
- window.location.assign(withBaseHref);
87
- return;
83
+ const preloadChunkThenNavigate = async () => {
84
+ const inCurrPage = isActive(removeBaseHref, currPagePathname);
85
+ if (!process.env.__SSR__ && !inCurrPage) {
86
+ const matchedRoute = pathnameToRouteService(removeBaseHref);
87
+ if (matchedRoute) {
88
+ const timer = setTimeout(() => {
89
+ nprogress.start();
90
+ }, 200);
91
+ await matchedRoute.preload();
92
+ clearTimeout(timer);
93
+ nprogress.done();
94
+ } else {
95
+ window.location.assign(withBaseHref);
96
+ return;
97
+ }
88
98
  }
99
+ navigate(removeBaseHref, { replace: false });
100
+ };
101
+
102
+ if (startTransition) {
103
+ startTransition(preloadChunkThenNavigate);
104
+ } else {
105
+ preloadChunkThenNavigate();
89
106
  }
90
- navigate(removeBaseHref, { replace: false });
91
107
  },
92
108
  [currPagePathname, navigate],
93
109
  );
@@ -24,6 +24,7 @@
24
24
  cursor: pointer;
25
25
  justify-content: center;
26
26
  align-items: center;
27
+ height: 100%;
27
28
  gap: 6px;
28
29
 
29
30
  // text
@@ -6,8 +6,7 @@ import type {
6
6
  } from '@rspress/core';
7
7
  import { matchNavbar, useLocation } from '@rspress/core/runtime';
8
8
  import type { HoverGroupProps } from '@theme';
9
- import { Link, SvgWrapper, Tag, useHoverGroup } from '@theme';
10
- import ArrowDown from '@theme-assets/arrow-down';
9
+ import { IconArrowDown, Link, SvgWrapper, Tag, useHoverGroup } from '@theme';
11
10
  import cls from 'clsx';
12
11
  import { useMemo } from 'react';
13
12
  import { useLangsMenu, useVersionsMenu } from './hooks';
@@ -15,7 +14,7 @@ import './NavMenu.scss';
15
14
  import clsx from 'clsx';
16
15
 
17
16
  export const SvgDown = (props: React.SVGProps<SVGSVGElement>) => {
18
- return <SvgWrapper icon={ArrowDown} {...props} />;
17
+ return <SvgWrapper icon={IconArrowDown} {...props} />;
19
18
  };
20
19
 
21
20
  export function NavMenuItemWithChildren({
@@ -0,0 +1,11 @@
1
+ .rspress-logo {
2
+ height: 1.6rem;
3
+ }
4
+
5
+ .dark .rp-nav__title__logo-image--light {
6
+ display: none;
7
+ }
8
+
9
+ .dark .rp-nav__title__logo-image--dark {
10
+ display: block;
11
+ }
@@ -6,6 +6,7 @@ import {
6
6
  } from '@rspress/core/runtime';
7
7
  import { Link } from '@theme';
8
8
  import { useMemo } from 'react';
9
+ import './NavTitle.scss';
9
10
 
10
11
  export const NavTitle = () => {
11
12
  const { site } = useSite();
@@ -91,11 +91,3 @@
91
91
  }
92
92
  }
93
93
  }
94
-
95
- .dark .rp-nav__title__logo-image--light {
96
- display: none;
97
- }
98
-
99
- .dark .rp-nav__title__logo-image--dark {
100
- display: block;
101
- }
@@ -1,5 +1,4 @@
1
- import { SocialLinks, SvgWrapper, useHoverGroup } from '@theme';
2
- import SmallMenu from '@theme-assets/small-menu';
1
+ import { IconSmallMenu, SocialLinks, SvgWrapper, useHoverGroup } from '@theme';
3
2
  import clsx from 'clsx';
4
3
  import { createPortal } from 'react-dom';
5
4
  import { NavVersions } from '../Nav/NavMenu';
@@ -43,7 +42,7 @@ export function NavHamburger() {
43
42
  'rp-nav-hamburger--active': isScreenOpen,
44
43
  })}
45
44
  >
46
- <SvgWrapper icon={SmallMenu} />
45
+ <SvgWrapper icon={IconSmallMenu} />
47
46
  </button>
48
47
 
49
48
  <button
@@ -55,7 +54,7 @@ export function NavHamburger() {
55
54
  onMouseEnter={handleMouseEnter}
56
55
  onMouseLeave={handleMouseLeave}
57
56
  >
58
- <SvgWrapper icon={SmallMenu} />
57
+ <SvgWrapper icon={IconSmallMenu} />
59
58
  {hoverGroup}
60
59
  </button>
61
60
  </>
@@ -56,4 +56,18 @@
56
56
  gap: 2px;
57
57
  margin-left: 8px;
58
58
  }
59
+
60
+ // external link
61
+ &.rp-link[target='_blank'] {
62
+ .rp-nav-screen-menu-item__left {
63
+ &::after {
64
+ content: '↗';
65
+ font-weight: 400;
66
+ color: var(--rp-c-text-3);
67
+ transform: translate(0, -0.2em);
68
+ margin-left: 0.2em;
69
+ margin-right: 0.1em;
70
+ }
71
+ }
72
+ }
59
73
  }
@@ -5,8 +5,7 @@ import type {
5
5
  NavItemWithLinkAndChildren,
6
6
  } from '@rspress/core';
7
7
  import { matchNavbar, useLocation } from '@rspress/core/runtime';
8
- import { Link, SvgWrapper, Tag } from '@theme';
9
- import ArrowDown from '@theme-assets/arrow-down';
8
+ import { IconArrowDown, Link, SvgWrapper, Tag } from '@theme';
10
9
  import clsx from 'clsx';
11
10
  import type React from 'react';
12
11
  import { useMemo, useState } from 'react';
@@ -17,7 +16,7 @@ interface NavScreenMenuItemWithLinkProps {
17
16
  }
18
17
 
19
18
  export const SvgDown = (props: React.SVGProps<SVGSVGElement>) => {
20
- return <SvgWrapper icon={ArrowDown} {...props} />;
19
+ return <SvgWrapper icon={IconArrowDown} {...props} />;
21
20
  };
22
21
 
23
22
  export function NavScreenMenuItemRaw({
@@ -43,7 +43,6 @@
43
43
  display: flex;
44
44
  flex-direction: column;
45
45
  flex: 1;
46
- gap: 6px;
47
46
 
48
47
  // allow scroll when there are too many toc items
49
48
  @media (max-width: 1280px) {
@@ -1,8 +1,7 @@
1
1
  import { Link, renderInlineMarkdown } from '@theme';
2
2
  import './OverviewGroup.scss';
3
3
  import type { Header } from '@rspress/core';
4
- import { SvgWrapper } from '@theme';
5
- import { FallbackHeading } from '../DocContent/FallbackHeading';
4
+ import { FallbackHeading, SvgWrapper } from '@theme';
6
5
  import IconPlugin from './icons/plugin.svg';
7
6
 
8
7
  export interface GroupItem {
@@ -10,9 +10,13 @@ import {
10
10
  usePageData,
11
11
  useSidebar,
12
12
  } from '@rspress/core/runtime';
13
- import { type Group, type GroupItem, OverviewGroup } from '@theme';
13
+ import {
14
+ FallbackHeading,
15
+ type Group,
16
+ type GroupItem,
17
+ OverviewGroup,
18
+ } from '@theme';
14
19
  import { useEffect, useMemo, useRef, useState } from 'react';
15
- import { FallbackHeading } from '../DocContent/FallbackHeading';
16
20
  import {
17
21
  isSidebarDivider,
18
22
  isSidebarSectionHeader,
@@ -210,6 +210,18 @@ export function PackageManagerTabs({
210
210
  commandInfo = command;
211
211
  }
212
212
 
213
+ if (process.env.__SSR_MD__) {
214
+ return Object.values(commandInfo).reduce((previous, current) => {
215
+ const [packageManager, command] = splitTo2Parts(current);
216
+ return (
217
+ previous +
218
+ `\n\`\`\`sh [${packageManager}]\n` +
219
+ `${packageManager}${command}\n` +
220
+ `\`\`\`\n`
221
+ );
222
+ }, '');
223
+ }
224
+
213
225
  return (
214
226
  <Tabs
215
227
  groupId="package.manager"
@@ -1,11 +1,11 @@
1
1
  import { useI18n } from '@rspress/core/runtime';
2
2
  import {
3
+ IconArrowRight,
3
4
  Link,
4
5
  renderInlineMarkdown,
5
6
  SvgWrapper,
6
7
  usePrevNextPage,
7
8
  } from '@theme';
8
- import ArrowRight from '@theme-assets/arrow-right';
9
9
  import clsx from 'clsx';
10
10
  import './index.scss';
11
11
 
@@ -25,7 +25,7 @@ export function PrevNextPage() {
25
25
  </span>
26
26
  <span className="rp-prev-next-page__item__title">
27
27
  <SvgWrapper
28
- icon={ArrowRight}
28
+ icon={IconArrowRight}
29
29
  className="rp-prev-next-page__icon rp-prev-next-page__rotate_180"
30
30
  />
31
31
  <span {...renderInlineMarkdown(prevPage.text)} />
@@ -44,7 +44,10 @@ export function PrevNextPage() {
44
44
  </span>
45
45
  <span className="rp-prev-next-page__item__title">
46
46
  <span {...renderInlineMarkdown(nextPage.text)} />
47
- <SvgWrapper icon={ArrowRight} className="rp-prev-next-page__icon" />
47
+ <SvgWrapper
48
+ icon={IconArrowRight}
49
+ className="rp-prev-next-page__icon"
50
+ />
48
51
  </span>
49
52
  </Link>
50
53
  ) : (
@@ -0,0 +1,58 @@
1
+ import type { ReactNode } from 'react';
2
+
3
+ export interface RootProps {
4
+ /**
5
+ * The children elements to render inside the Root component.
6
+ */
7
+ children: ReactNode;
8
+ }
9
+
10
+ /**
11
+ * A wrapper component for the entire application.
12
+ *
13
+ * The Root component wraps all content in the application, including the Layout
14
+ * and global UI components. By default, it simply renders its children without
15
+ * any additional markup or styling.
16
+ *
17
+ * You can eject and customize this component to add global wrappers, providers,
18
+ * or any other elements that should wrap your entire application.
19
+ *
20
+ * @param {RootProps} props - The properties for the Root component.
21
+ * @returns {JSX.Element} The children elements wrapped by the Root component.
22
+ *
23
+ * @example
24
+ * Default usage (no customization needed):
25
+ * ```tsx
26
+ * import { Root } from '@theme';
27
+ *
28
+ * function App() {
29
+ * return (
30
+ * <Root>
31
+ * <YourContent />
32
+ * </Root>
33
+ * );
34
+ * }
35
+ * ```
36
+ *
37
+ * @example
38
+ * Ejected and customized:
39
+ * ```tsx
40
+ * // In your ejected theme/components/Root/index.tsx
41
+ * import type { ReactNode } from 'react';
42
+ *
43
+ * export interface RootProps {
44
+ * children: ReactNode;
45
+ * }
46
+ *
47
+ * export function Root({ children }: RootProps) {
48
+ * return (
49
+ * <div className="my-custom-root">
50
+ * {children}
51
+ * </div>
52
+ * );
53
+ * }
54
+ * ```
55
+ */
56
+ export function Root({ children }: RootProps) {
57
+ return <>{children}</>;
58
+ }
@@ -1,6 +1,5 @@
1
1
  import { useI18n } from '@rspress/core/runtime';
2
- import { SvgWrapper } from '@theme';
3
- import Empty from '@theme-assets/empty';
2
+ import { IconEmpty, SvgWrapper } from '@theme';
4
3
  import './NoSearchResult.scss';
5
4
 
6
5
  export function NoSearchResult({ query }: { query: string }) {
@@ -8,7 +7,7 @@ export function NoSearchResult({ query }: { query: string }) {
8
7
 
9
8
  return (
10
9
  <div className="rp-no-search-result">
11
- <SvgWrapper icon={Empty} className="rp-no-search-result__icon" />
10
+ <SvgWrapper icon={IconEmpty} className="rp-no-search-result__icon" />
12
11
  <p className="rp-no-search-result__text">
13
12
  {t('searchNoResultsText')} <b>&quot;{query}&quot;</b>
14
13
  </p>
@@ -1,6 +1,5 @@
1
1
  import { useI18n } from '@rspress/core/runtime';
2
- import { SvgWrapper } from '@theme';
3
- import SearchSvg from '@theme-assets/search';
2
+ import { IconSearch, SvgWrapper } from '@theme';
4
3
  import { useEffect, useState } from 'react';
5
4
  import './SearchButton.scss';
6
5
 
@@ -20,7 +19,7 @@ export function SearchButton({ setFocused }: SearchButtonProps) {
20
19
  <>
21
20
  <button className="rp-search-button" onClick={() => setFocused(true)}>
22
21
  <div className="rp-search-button__content">
23
- <SvgWrapper icon={SearchSvg} className="rp-search-button__icon" />
22
+ <SvgWrapper icon={IconSearch} className="rp-search-button__icon" />
24
23
  <span className="rp-search-button__word">
25
24
  {t('searchPlaceholderText')}
26
25
  </span>
@@ -37,7 +36,7 @@ export function SearchButton({ setFocused }: SearchButtonProps) {
37
36
  className="rp-search-button--mobile"
38
37
  onClick={() => setFocused(true)}
39
38
  >
40
- <SvgWrapper icon={SearchSvg} />
39
+ <SvgWrapper icon={IconSearch} />
41
40
  </div>
42
41
  </>
43
42
  );
@@ -1,8 +1,13 @@
1
1
  import { useI18n, usePageData } from '@rspress/core/runtime';
2
- import { SvgWrapper, Tab, Tabs, useLinkNavigate } from '@theme';
3
- import CloseSvg from '@theme-assets/close';
4
- import LoadingSvg from '@theme-assets/loading';
5
- import SearchSvg from '@theme-assets/search';
2
+ import {
3
+ IconClose,
4
+ IconLoading,
5
+ IconSearch,
6
+ SvgWrapper,
7
+ Tab,
8
+ Tabs,
9
+ useLinkNavigate,
10
+ } from '@theme';
6
11
  import { debounce } from 'lodash-es';
7
12
  import { useCallback, useEffect, useRef, useState } from 'react';
8
13
  import { createPortal } from 'react-dom';
@@ -232,8 +237,8 @@ export function SearchPanel({ focused, setFocused }: SearchPanelProps) {
232
237
  currentRenderType === RenderType.Default
233
238
  ) {
234
239
  // the ResultItem has been normalized to display
235
- const flatSuggestions = Object.values(
236
- normalizeSuggestions(currentSuggestions),
240
+ const flatSuggestions = Array.from(
241
+ normalizeSuggestions(currentSuggestions).values(),
237
242
  ).flat();
238
243
  const suggestion = flatSuggestions[currentSuggestionIndex];
239
244
  navigate(suggestion.link);
@@ -418,7 +423,7 @@ export function SearchPanel({ focused, setFocused }: SearchPanelProps) {
418
423
  if (isSearching) {
419
424
  return (
420
425
  <div className="rp-search-panel__loading">
421
- <SvgWrapper icon={LoadingSvg} />
426
+ <SvgWrapper icon={IconLoading} />
422
427
  </div>
423
428
  );
424
429
  }
@@ -499,7 +504,7 @@ export function SearchPanel({ focused, setFocused }: SearchPanelProps) {
499
504
  <div className="rp-search-panel__header">
500
505
  <div className="rp-search-panel__input-form">
501
506
  <label>
502
- <SvgWrapper icon={SearchSvg} />
507
+ <SvgWrapper icon={IconSearch} />
503
508
  </label>
504
509
  <input
505
510
  className="rp-search-panel__input"
@@ -512,7 +517,7 @@ export function SearchPanel({ focused, setFocused }: SearchPanelProps) {
512
517
  />
513
518
  <label>
514
519
  <SvgWrapper
515
- icon={CloseSvg}
520
+ icon={IconClose}
516
521
  className="rp-search-panel__close"
517
522
  onClick={e => {
518
523
  if (searchInputRef.current) {
@@ -1,19 +1,16 @@
1
- import { Link, SvgWrapper } from '@theme';
2
- import FileSvg from '@theme-assets/file';
3
- import HeaderSvg from '@theme-assets/header';
4
- import JumpSvg from '@theme-assets/jump';
5
- import TitleSvg from '@theme-assets/title';
1
+ import {
2
+ IconFile,
3
+ IconHeader,
4
+ IconJump,
5
+ IconTitle,
6
+ Link,
7
+ SvgWrapper,
8
+ } from '@theme';
6
9
  import { useRef } from 'react';
7
10
  import './SuggestItem.scss';
8
11
  import type { DefaultMatchResultItem, HighlightInfo } from './logic/types';
9
12
  import { getSlicedStrByByteLength } from './logic/util';
10
13
 
11
- const ICON_MAP = {
12
- title: TitleSvg,
13
- header: HeaderSvg,
14
- content: FileSvg,
15
- };
16
-
17
14
  export function SuggestItem({
18
15
  suggestion,
19
16
  closeSearch,
@@ -32,6 +29,12 @@ export function SuggestItem({
32
29
  inCurrentDocIndex: boolean;
33
30
  scrollTo: (top: number, height: number) => void;
34
31
  }) {
32
+ const ICON_MAP = {
33
+ title: IconTitle,
34
+ header: IconHeader,
35
+ content: IconFile,
36
+ };
37
+
35
38
  const HitIcon = ICON_MAP[suggestion.type];
36
39
  const selfRef = useRef<HTMLLIElement>(null);
37
40
  if (isCurrent && selfRef.current?.offsetTop) {
@@ -135,7 +138,7 @@ export function SuggestItem({
135
138
  <span>{hitContent}</span>
136
139
  </div>
137
140
  <div className="rp-suggest-item__action-icon">
138
- <SvgWrapper icon={JumpSvg} />
141
+ <SvgWrapper icon={IconJump} />
139
142
  </div>
140
143
  </div>
141
144
  </Link>
@@ -5,8 +5,7 @@ import type {
5
5
  SidebarSectionHeader as SidebarSectionHeaderType,
6
6
  } from '@rspress/core';
7
7
  import { useActiveMatcher } from '@rspress/core/runtime';
8
- import { SvgWrapper, useLinkNavigate } from '@theme';
9
- import ArrowRight from '@theme-assets/arrow-right';
8
+ import { IconArrowRight, SvgWrapper, useLinkNavigate } from '@theme';
10
9
  import clsx from 'clsx';
11
10
  import type React from 'react';
12
11
  import { SidebarDivider } from './SidebarDivider';
@@ -27,7 +26,7 @@ const CollapsibleIcon = ({ collapsed }: { collapsed: boolean }) => (
27
26
  transform: collapsed ? 'rotate(0deg)' : 'rotate(90deg)',
28
27
  }}
29
28
  >
30
- <SvgWrapper icon={ArrowRight} />
29
+ <SvgWrapper icon={IconArrowRight} />
31
30
  </div>
32
31
  );
33
32