@rspress/core 2.0.0-rc.1 → 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 (256) 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/Callout/index.scss +0 -2
  16. package/dist/eject-theme/components/CodeBlock/index.scss +4 -12
  17. package/dist/eject-theme/components/CodeBlock/index.tsx +6 -1
  18. package/dist/eject-theme/components/CodeButtonGroup/CopyCodeButton.tsx +1 -3
  19. package/dist/eject-theme/components/CodeButtonGroup/index.scss +5 -1
  20. package/dist/eject-theme/components/CodeButtonGroup/index.tsx +1 -3
  21. package/dist/eject-theme/components/DocContent/doc.scss +27 -7
  22. package/dist/eject-theme/components/DocContent/docComponents/table.tsx +10 -4
  23. package/dist/eject-theme/components/DocContent/index.tsx +3 -3
  24. package/dist/eject-theme/components/{DocContent/FallbackHeading.tsx → FallbackHeading/index.tsx} +20 -11
  25. package/dist/eject-theme/components/Link/index.tsx +13 -4
  26. package/dist/eject-theme/components/Nav/NavMenu.tsx +2 -3
  27. package/dist/eject-theme/components/NavHamburger/index.tsx +3 -4
  28. package/dist/eject-theme/components/NavScreen/NavScreenMenuItem.tsx +2 -3
  29. package/dist/eject-theme/components/Overview/OverviewGroup.tsx +1 -2
  30. package/dist/eject-theme/components/Overview/index.tsx +6 -2
  31. package/dist/eject-theme/components/PackageManagerTabs/index.tsx +12 -0
  32. package/dist/eject-theme/components/PrevNextPage/index.tsx +6 -3
  33. package/dist/eject-theme/components/Root/index.tsx +58 -0
  34. package/dist/eject-theme/components/Search/NoSearchResult.tsx +2 -3
  35. package/dist/eject-theme/components/Search/SearchButton.tsx +3 -4
  36. package/dist/eject-theme/components/Search/SearchPanel.tsx +12 -7
  37. package/dist/eject-theme/components/Search/SuggestItem.tsx +15 -12
  38. package/dist/eject-theme/components/Sidebar/SidebarGroup.tsx +2 -3
  39. package/dist/eject-theme/components/Sidebar/SidebarItem.tsx +1 -0
  40. package/dist/eject-theme/components/SidebarMenu/index.tsx +4 -4
  41. package/dist/eject-theme/components/SocialLinks/index.tsx +2 -3
  42. package/dist/eject-theme/components/SourceCode/index.tsx +6 -4
  43. package/dist/eject-theme/components/SwitchAppearance/index.tsx +3 -5
  44. package/dist/eject-theme/components/Tabs/index.scss +19 -22
  45. package/dist/eject-theme/components/Toc/TocItem.scss +3 -3
  46. package/dist/eject-theme/components/Toc/TocItem.tsx +1 -0
  47. package/dist/index.d.ts +6 -6
  48. package/dist/index.js +16 -3134
  49. package/dist/node/PluginDriver.d.ts +1 -1
  50. package/dist/node/PluginDriver.js +143 -0
  51. package/dist/node/auto-nav-sidebar/index.js +44 -0
  52. package/dist/node/auto-nav-sidebar/locales.js +26 -0
  53. package/dist/node/auto-nav-sidebar/normalize.js +228 -0
  54. package/dist/node/auto-nav-sidebar/utils.js +68 -0
  55. package/dist/node/auto-nav-sidebar/walk.js +67 -0
  56. package/dist/node/build.js +31 -0
  57. package/dist/node/constants.d.ts +1 -0
  58. package/dist/node/constants.js +33 -0
  59. package/dist/node/dev.js +32 -0
  60. package/dist/node/eject.js +111 -0
  61. package/dist/node/index.d.ts +5 -5
  62. package/dist/node/initRsbuild.d.ts +2 -2
  63. package/dist/node/initRsbuild.js +338 -0
  64. package/dist/node/last-updated/index.js +28 -0
  65. package/dist/node/logger/hint.d.ts +1 -1
  66. package/dist/node/logger/hint.js +85 -0
  67. package/dist/node/mdx/loader.d.ts +1 -1
  68. package/dist/node/mdx/loader.e1578c62.js +13 -0
  69. package/dist/{loader.js → node/mdx/loader.js} +2 -2
  70. package/dist/node/mdx/options.d.ts +2 -2
  71. package/dist/node/mdx/options.js +100 -0
  72. package/dist/node/mdx/processor.d.ts +2 -2
  73. package/dist/node/mdx/processor.js +71 -0
  74. package/dist/node/mdx/rehypePlugins/codeMeta.js +10 -0
  75. package/dist/node/mdx/rehypePlugins/headerAnchor.js +53 -0
  76. package/dist/node/mdx/rehypePlugins/shiki.js +34 -0
  77. package/dist/node/mdx/rehypePlugins/transformers/add-lang.js +15 -0
  78. package/dist/node/mdx/rehypePlugins/transformers/add-line-numbers.js +22 -0
  79. package/dist/node/mdx/rehypePlugins/transformers/add-title.js +24 -0
  80. package/dist/node/mdx/rehypePlugins/transformers/add-wrap-code.js +22 -0
  81. package/dist/node/mdx/rehypePlugins/transformers/index.d.ts +5 -5
  82. package/dist/node/mdx/rehypePlugins/transformers/index.js +5 -0
  83. package/dist/node/mdx/rehypePlugins/transformers/meta-highlight.js +41 -0
  84. package/dist/node/mdx/remarkPlugins/builtin.js +11 -0
  85. package/dist/node/mdx/remarkPlugins/containerSyntax.js +190 -0
  86. package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +66 -0
  87. package/dist/node/mdx/remarkPlugins/image.js +67 -0
  88. package/dist/node/mdx/remarkPlugins/link.d.ts +1 -1
  89. package/dist/node/mdx/remarkPlugins/link.js +99 -0
  90. package/dist/node/mdx/remarkPlugins/toc.js +50 -0
  91. package/dist/node/mdx/types.d.ts +3 -3
  92. package/dist/node/medium-zoom/index.d.ts +1 -1
  93. package/dist/node/medium-zoom/index.js +14 -0
  94. package/dist/node/route/RoutePage.d.ts +1 -1
  95. package/dist/node/route/RoutePage.js +61 -0
  96. package/dist/node/route/RouteService.d.ts +1 -1
  97. package/dist/node/route/RouteService.js +177 -0
  98. package/dist/node/route/extractPageData.d.ts +1 -1
  99. package/dist/node/route/extractPageData.js +112 -0
  100. package/dist/node/route/normalizeRoutePath.js +54 -0
  101. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.d.ts +21 -0
  102. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.js +150 -0
  103. package/dist/node/runtimeModule/globalStyles.d.ts +1 -1
  104. package/dist/node/runtimeModule/globalStyles.js +12 -0
  105. package/dist/node/runtimeModule/globalUIComponents.d.ts +1 -1
  106. package/dist/node/runtimeModule/globalUIComponents.js +25 -0
  107. package/dist/node/runtimeModule/i18n.d.ts +2 -2
  108. package/dist/node/runtimeModule/i18n.js +83 -0
  109. package/dist/node/runtimeModule/pageData/createPageData.d.ts +1 -1
  110. package/dist/node/runtimeModule/pageData/createPageData.js +64 -0
  111. package/dist/node/runtimeModule/pageData/rsbuildPlugin.d.ts +1 -1
  112. package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +51 -0
  113. package/dist/node/runtimeModule/routeList.d.ts +1 -1
  114. package/dist/node/runtimeModule/routeList.js +7 -0
  115. package/dist/node/runtimeModule/searchHooks.d.ts +1 -1
  116. package/dist/node/runtimeModule/searchHooks.js +11 -0
  117. package/dist/node/runtimeModule/siteData/createSiteData.js +34 -0
  118. package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +94 -0
  119. package/dist/node/runtimeModule/siteData/rsbuildPlugin.d.ts +1 -1
  120. package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +24 -0
  121. package/dist/node/runtimeModule/socialLinks.d.ts +1 -1
  122. package/dist/node/runtimeModule/socialLinks.js +8 -0
  123. package/dist/node/runtimeModule/types.d.ts +2 -2
  124. package/dist/node/serve.js +23 -0
  125. package/dist/node/ssg/renderHtmlTemplate.js +33 -0
  126. package/dist/node/ssg/renderPage.js +34 -0
  127. package/dist/node/ssg/renderPageWorker.474f9f73.js +2 -0
  128. package/dist/node/ssg/renderPageWorker.js +15 -0
  129. package/dist/node/ssg/renderPages.d.ts +1 -1
  130. package/dist/node/ssg/renderPages.js +105 -0
  131. package/dist/node/ssg/renderPages.js.LICENSE.txt +4 -0
  132. package/dist/node/ssg/rsbuildPluginCSR.d.ts +1 -1
  133. package/dist/node/ssg/rsbuildPluginCSR.js +27 -0
  134. package/dist/node/ssg/rsbuildPluginSSG.d.ts +1 -1
  135. package/dist/node/ssg/rsbuildPluginSSG.js +72 -0
  136. package/dist/node/ssg/ssgEnv.js +33 -0
  137. package/dist/node/ssg/ssgEnv.js.LICENSE.txt +5 -0
  138. package/dist/node/ssg-md/llms/emitLlmsTxt.d.ts +1 -1
  139. package/dist/node/ssg-md/llms/emitLlmsTxt.js +80 -0
  140. package/dist/node/ssg-md/llms/llmsTxt.d.ts +1 -1
  141. package/dist/node/ssg-md/llms/llmsTxt.js +66 -0
  142. package/dist/node/ssg-md/react/index.d.ts +1 -1
  143. package/dist/node/ssg-md/remarkSplitMdx.js +202 -0
  144. package/dist/node/ssg-md/renderPage.js +31 -0
  145. package/dist/node/ssg-md/renderPages.d.ts +1 -1
  146. package/dist/node/ssg-md/renderPages.js +27 -0
  147. package/dist/node/ssg-md/rsbuildPluginSSGMD.d.ts +1 -1
  148. package/dist/node/ssg-md/rsbuildPluginSSGMD.js +47 -0
  149. package/dist/node/utils/applyReplaceRules.js +6 -0
  150. package/dist/node/utils/checkLanguageParity.js +77 -0
  151. package/dist/node/utils/createHash.js +5 -0
  152. package/dist/node/utils/error.d.ts +9 -0
  153. package/dist/node/utils/error.js +9 -0
  154. package/dist/node/utils/escapeHeadingIds.js +5 -0
  155. package/dist/node/utils/flattenMdxContent.js +74 -0
  156. package/dist/node/utils/fs.js +14 -0
  157. package/dist/node/utils/getImportAstNode.js +63 -0
  158. package/dist/node/utils/getPageKey.js +6 -0
  159. package/dist/node/utils/getSocialIcons.js +32 -0
  160. package/dist/node/utils/index.d.ts +10 -9
  161. package/dist/node/utils/normalizePath.js +10 -0
  162. package/dist/node/utils/reactAlias.d.ts +2 -0
  163. package/dist/node/utils/reactAlias.js +83 -0
  164. package/dist/rslib-runtime.99091bf6.js +18 -0
  165. package/dist/runtime/App.js +2 -2
  166. package/dist/runtime/ClientApp.d.ts +1 -1
  167. package/dist/runtime/ClientApp.js +0 -4
  168. package/dist/runtime/ssrMdServerEntry.js +1 -1
  169. package/dist/runtime/ssrServerEntry.js +2 -1
  170. package/dist/runtime.72d450ac.js +1 -0
  171. package/dist/runtime.js +3 -2
  172. package/dist/shiki-transformers.d.ts +1 -1
  173. package/dist/shiki-transformers.js +6 -120
  174. package/dist/theme/components/Banner/index.d.ts +1 -1
  175. package/dist/theme/components/Banner/index.js +2 -3
  176. package/dist/theme/components/Callout/index.css +0 -2
  177. package/dist/theme/components/CodeBlock/index.css +4 -15
  178. package/dist/theme/components/CodeBlock/index.js +1 -0
  179. package/dist/theme/components/CodeButtonGroup/CopyCodeButton.js +3 -5
  180. package/dist/theme/components/CodeButtonGroup/index.css +5 -1
  181. package/dist/theme/components/CodeButtonGroup/index.js +3 -5
  182. package/dist/theme/components/DocContent/doc.css +28 -7
  183. package/dist/theme/components/DocContent/docComponents/index.d.ts +3 -3
  184. package/dist/theme/components/DocContent/docComponents/table.d.ts +2 -2
  185. package/dist/theme/components/DocContent/docComponents/table.js +8 -3
  186. package/dist/theme/components/DocContent/index.js +2 -3
  187. package/dist/theme/components/{DocContent/FallbackHeading.js → FallbackHeading/index.js} +19 -11
  188. package/dist/theme/components/HoverGroup/useHoverGroup.d.ts +1 -1
  189. package/dist/theme/components/Link/index.js +9 -5
  190. package/dist/theme/components/Nav/NavMenu.js +2 -3
  191. package/dist/theme/components/NavHamburger/index.js +3 -4
  192. package/dist/theme/components/NavScreen/NavScreenMenuItem.js +2 -3
  193. package/dist/theme/components/Overview/OverviewGroup.js +1 -2
  194. package/dist/theme/components/Overview/index.js +1 -2
  195. package/dist/theme/components/PackageManagerTabs/index.d.ts +1 -1
  196. package/dist/theme/components/PackageManagerTabs/index.js +4 -0
  197. package/dist/theme/components/PrevNextPage/index.js +3 -4
  198. package/dist/theme/components/Root/index.d.ts +54 -0
  199. package/dist/theme/components/Root/index.js +7 -0
  200. package/dist/theme/components/Search/NoSearchResult.js +2 -3
  201. package/dist/theme/components/Search/SearchButton.js +3 -4
  202. package/dist/theme/components/Search/SearchPanel.js +12 -15
  203. package/dist/theme/components/Search/SuggestItem.d.ts +1 -1
  204. package/dist/theme/components/Search/SuggestItem.js +7 -11
  205. package/dist/theme/components/Search/logic/Provider.d.ts +1 -1
  206. package/dist/theme/components/Search/logic/providers/LocalProvider.d.ts +2 -2
  207. package/dist/theme/components/Search/logic/search.d.ts +1 -1
  208. package/dist/theme/components/Sidebar/SidebarGroup.js +2 -3
  209. package/dist/theme/components/Sidebar/SidebarItem.js +1 -0
  210. package/dist/theme/components/SidebarMenu/index.js +3 -5
  211. package/dist/theme/components/SocialLinks/index.js +2 -3
  212. package/dist/theme/components/SourceCode/index.js +2 -4
  213. package/dist/theme/components/SwitchAppearance/index.js +3 -5
  214. package/dist/theme/components/Tabs/index.css +13 -22
  215. package/dist/theme/components/Toc/TocItem.css +2 -3
  216. package/dist/theme/components/Toc/TocItem.js +1 -0
  217. package/dist/theme/icons.d.ts +25 -0
  218. package/dist/theme/icons.js +47 -0
  219. package/dist/theme/index.d.ts +62 -59
  220. package/dist/theme/index.js +4 -1
  221. package/dist/theme/layout/DocLayout/index.css +2 -2
  222. package/dist/theme/logic/useFullTextSearch.d.ts +1 -1
  223. package/dist/theme/styles/scrollbar.css +1 -0
  224. package/dist/theme/styles/vars/base-vars.css +5 -3
  225. package/dist/theme/styles/vars/home-vars.css +2 -1
  226. package/package.json +17 -18
  227. package/dist/3~128.js +0 -74
  228. package/dist/3~517.js +0 -1786
  229. package/dist/3~894.js +0 -26
  230. package/dist/cli.js +0 -259
  231. package/dist/index.js.LICENSE.txt +0 -10
  232. package/dist/node/auto-nav-sidebar/fixtures/docs/guide/c.d.ts +0 -2
  233. package/dist/node/auto-nav-sidebar/fixtures/docs-locales/en/guide/c.d.ts +0 -2
  234. package/dist/node/auto-nav-sidebar/fixtures/docs-locales/zh/guide/c.d.ts +0 -2
  235. package/dist/node/auto-nav-sidebar/locales.test.d.ts +0 -1
  236. package/dist/node/auto-nav-sidebar/walk.test.d.ts +0 -1
  237. package/dist/node/mdx/rehypePlugins/headerAnchor.test.d.ts +0 -1
  238. package/dist/node/mdx/remarkPlugins/containerSyntax.test.d.ts +0 -1
  239. package/dist/node/mdx/remarkPlugins/fileCodeBlock.test.d.ts +0 -1
  240. package/dist/node/mdx/remarkPlugins/image.test.d.ts +0 -1
  241. package/dist/node/mdx/remarkPlugins/link.test.d.ts +0 -1
  242. package/dist/node/route/RouteService.test.d.ts +0 -1
  243. package/dist/node/route/extractPageData.test.d.ts +0 -1
  244. package/dist/node/route/fixtures/basic/guide/c.d.ts +0 -2
  245. package/dist/node/route/normalizeRoutePath.test.d.ts +0 -1
  246. package/dist/node/runtimeModule/i18n.test.d.ts +0 -1
  247. package/dist/node/ssg-md/remarkSplitMdx.test.d.ts +0 -4
  248. package/dist/node/utils/checkLanguageParity.test.d.ts +0 -1
  249. package/dist/node/utils/detectCustomIcon.d.ts +0 -1
  250. package/dist/node/utils/detectReactVersion.d.ts +0 -3
  251. package/dist/processor.js +0 -4539
  252. package/dist/renderPageWorker.js +0 -196
  253. package/dist/theme/components/Search/logic/util.test.d.ts +0 -1
  254. /package/dist/cli/{config.d.ts → config/index.d.ts} +0 -0
  255. /package/dist/{shiki-transformers.js.LICENSE.txt → node/mdx/rehypePlugins/transformers/meta-highlight.js.LICENSE.txt} +0 -0
  256. /package/dist/theme/components/{DocContent/FallbackHeading.d.ts → FallbackHeading/index.d.ts} +0 -0
@@ -51,6 +51,7 @@ export function Link(props: LinkProps) {
51
51
  onClick,
52
52
  onMouseEnter,
53
53
  startTransition,
54
+ ...otherProps
54
55
  } = props;
55
56
 
56
57
  const { linkType, removeBaseHref, withBaseHref } = getHref(href);
@@ -59,11 +60,13 @@ export function Link(props: LinkProps) {
59
60
  if (linkType === 'external') {
60
61
  return (
61
62
  <a
62
- {...props}
63
63
  href={href}
64
64
  target="_blank"
65
65
  rel="noopener noreferrer"
66
66
  className={clsx(className, 'rp-link')}
67
+ onClick={onClick}
68
+ onMouseEnter={onMouseEnter}
69
+ {...otherProps}
67
70
  >
68
71
  {children}
69
72
  </a>
@@ -72,7 +75,13 @@ export function Link(props: LinkProps) {
72
75
 
73
76
  if (linkType === 'hashOnly') {
74
77
  return (
75
- <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
+ >
76
85
  {children}
77
86
  </a>
78
87
  );
@@ -81,7 +90,6 @@ export function Link(props: LinkProps) {
81
90
  if (linkType === 'relative') {
82
91
  return (
83
92
  <a
84
- {...props}
85
93
  href={href}
86
94
  className={clsx(className, 'rp-link')}
87
95
  onMouseEnter={event => {
@@ -106,6 +114,7 @@ export function Link(props: LinkProps) {
106
114
  e.preventDefault();
107
115
  navigate(href);
108
116
  }}
117
+ {...otherProps}
109
118
  >
110
119
  {children}
111
120
  </a>
@@ -114,7 +123,6 @@ export function Link(props: LinkProps) {
114
123
 
115
124
  return (
116
125
  <a
117
- {...props}
118
126
  href={withBaseHref}
119
127
  className={clsx(className, 'rp-link')}
120
128
  onMouseEnter={event => {
@@ -139,6 +147,7 @@ export function Link(props: LinkProps) {
139
147
  e.preventDefault();
140
148
  navigate(removeBaseHref);
141
149
  }}
150
+ {...otherProps}
142
151
  >
143
152
  {children}
144
153
  </a>
@@ -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({
@@ -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
  </>
@@ -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({
@@ -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';
@@ -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
 
@@ -76,6 +76,7 @@ export function SidebarItemRaw({
76
76
  }}
77
77
  {...{ 'data-depth': depth }}
78
78
  {...(context ? { 'data-context': context } : {})}
79
+ onClick={onClick}
79
80
  >
80
81
  {innerContent}
81
82
  </Link>
@@ -1,13 +1,13 @@
1
1
  import { useFrontmatter, useI18n, useLocation } from '@rspress/core/runtime';
2
2
  import {
3
+ IconArrowRight,
4
+ IconMenu,
3
5
  ReadPercent,
4
6
  renderInlineMarkdown,
5
7
  SvgWrapper,
6
8
  useActiveAnchor,
7
9
  useDynamicToc,
8
10
  } from '@theme';
9
- import ArrowRight from '@theme-assets/arrow-right';
10
- import MenuIcon from '@theme-assets/menu';
11
11
  import { forwardRef, useEffect, useRef } from 'react';
12
12
  import { createPortal } from 'react-dom';
13
13
  import './index.scss';
@@ -85,7 +85,7 @@ export const SidebarMenu = forwardRef(
85
85
  onClick={openSidebar}
86
86
  className="rp-sidebar-menu__left"
87
87
  >
88
- <SvgWrapper icon={MenuIcon} />
88
+ <SvgWrapper icon={IconMenu} />
89
89
  <span>{t('menuTitle')}</span>
90
90
  </button>
91
91
  ) : (
@@ -114,7 +114,7 @@ export const SidebarMenu = forwardRef(
114
114
  {/* TODO: discussion */}
115
115
  {headers.length !== 0 && (
116
116
  <SvgWrapper
117
- icon={ArrowRight}
117
+ icon={IconArrowRight}
118
118
  style={{
119
119
  transform: isOutlineOpen ? 'rotate(90deg)' : 'rotate(0deg)',
120
120
  transition: 'transform 0.2s ease-out',
@@ -1,7 +1,6 @@
1
1
  import type { SocialLink } from '@rspress/core';
2
2
  import { useSite } from '@rspress/core/runtime';
3
- import { SvgWrapper } from '@theme';
4
- import ArrowDown from '@theme-assets/arrow-down';
3
+ import { IconArrowDown, SvgWrapper } from '@theme';
5
4
  import './index.scss';
6
5
  import { useHoverGroup } from '../HoverGroup/useHoverGroup';
7
6
  import { SocialLink as SocialLinkComp } from './SocialLink';
@@ -56,7 +55,7 @@ export const SocialLinks = ({
56
55
  ))}
57
56
  {isMore ? (
58
57
  <SvgWrapper
59
- icon={ArrowDown}
58
+ icon={IconArrowDown}
60
59
  onMouseEnter={handleMouseEnter}
61
60
  fontSize={20}
62
61
  />
@@ -1,7 +1,5 @@
1
1
  import { useI18n } from '@rspress/core/runtime';
2
- import { SvgWrapper } from '@theme';
3
- import Github from '@theme-assets/github';
4
- import Gitlab from '@theme-assets/gitlab';
2
+ import { IconGithub, IconGitlab, SvgWrapper } from '@theme';
5
3
  import './index.scss';
6
4
 
7
5
  interface SourceCodeProps {
@@ -16,7 +14,11 @@ export function SourceCode(props: SourceCodeProps) {
16
14
  <div className="rp-not-doc rp-source-code">
17
15
  <a href={href} target="_blank" className="rp-source-code__link">
18
16
  <span className="rp-source-code__icon">
19
- {<SvgWrapper icon={platform === 'gitlab' ? Gitlab : Github} />}
17
+ {
18
+ <SvgWrapper
19
+ icon={platform === 'gitlab' ? IconGitlab : IconGithub}
20
+ />
21
+ }
20
22
  </span>
21
23
  <span className="rp-source-code__text">{t('sourceCodeText')}</span>
22
24
  </a>
@@ -1,7 +1,5 @@
1
1
  import { ThemeContext, useSite } from '@rspress/core/runtime';
2
- import { SvgWrapper } from '@theme';
3
- import MoonSvg from '@theme-assets/moon';
4
- import SunSvg from '@theme-assets/sun';
2
+ import { IconMoon, IconSun, SvgWrapper } from '@theme';
5
3
  import { type MouseEvent, useContext } from 'react';
6
4
  import './global.scss';
7
5
  import './index.scss';
@@ -90,12 +88,12 @@ export function SwitchAppearance({ onClick }: { onClick?: () => void }) {
90
88
  <div onClick={handleClick} className="rp-switch-appearance">
91
89
  <SvgWrapper
92
90
  className="rp-switch-appearance__icon rp-switch-appearance__icon--sun"
93
- icon={SunSvg}
91
+ icon={IconSun}
94
92
  fill="currentColor"
95
93
  />
96
94
  <SvgWrapper
97
95
  className="rp-switch-appearance__icon rp-switch-appearance__icon--moon"
98
- icon={MoonSvg}
96
+ icon={IconMoon}
99
97
  fill="currentColor"
100
98
  />
101
99
  </div>
@@ -15,8 +15,7 @@
15
15
  }
16
16
 
17
17
  &__label {
18
- padding-left: 8px;
19
- padding-top: 4px;
18
+ padding: 4px 12px;
20
19
  display: flex;
21
20
  min-width: 100%;
22
21
  flex-wrap: wrap;
@@ -33,44 +32,36 @@
33
32
 
34
33
  &__item {
35
34
  word-break: keep-all;
35
+ font-size: 0.875rem;
36
36
 
37
37
  position: relative;
38
38
  color: var(--rp-c-text-2);
39
+
39
40
  box-sizing: border-box;
40
- margin-right: 10px;
41
- padding: 6px 12px;
41
+ margin-right: 4px;
42
+ padding: 4px 12px;
42
43
  user-select: none;
43
- transition: all 0.2s ease-in-out;
44
+ transition:
45
+ color 0.2s ease-out,
46
+ background-color 0.2s ease-out;
44
47
  cursor: pointer;
45
48
 
49
+ border-radius: var(--rp-radius-small);
50
+
46
51
  &:last-child {
47
52
  margin-right: 0;
48
53
  }
49
54
 
50
- &:after {
51
- content: '';
52
- position: absolute;
53
- bottom: 0;
54
- left: 5%;
55
- width: 90%;
56
- height: 1px;
57
- background-color: transparent;
58
- transition: background-color 0.3s ease-out;
59
- }
60
-
61
55
  &--not-selected {
62
56
  &:hover {
63
- color: var(--rp-c-text-0);
64
- opacity: 0.8;
57
+ background-color: var(--rp-c-bg-mute);
65
58
  }
66
59
  }
67
60
 
68
61
  &--selected {
69
62
  color: var(--rp-c-text-0);
70
-
71
- &:after {
72
- background-color: currentColor;
73
- }
63
+ background-color: var(--rp-c-bg);
64
+ box-shadow: 0px 0px 3px 0px var(--rp-c-divider);
74
65
  }
75
66
  }
76
67
  }
@@ -86,3 +77,9 @@
86
77
  }
87
78
  }
88
79
  }
80
+
81
+ .dark {
82
+ .rp-tabs__label__item--selected {
83
+ background-color: var(--rp-c-bg-soft);
84
+ }
85
+ }
@@ -2,10 +2,11 @@
2
2
  display: block;
3
3
  justify-content: flex-start;
4
4
  align-items: flex-start;
5
- gap: 10px;
6
5
  align-self: stretch;
7
6
  position: relative;
8
- margin-top: 6px;
7
+
8
+ margin-top: 10px;
9
+ line-height: 1.4;
9
10
 
10
11
  &:first-child {
11
12
  margin-top: 0;
@@ -14,7 +15,6 @@
14
15
  &__text {
15
16
  font-weight: 400;
16
17
  font-size: 14px;
17
- line-height: 1;
18
18
  color: var(--rp-c-text-2);
19
19
  overflow-wrap: break-word;
20
20
  }
@@ -43,6 +43,7 @@ export const TocItem = ({
43
43
  style={{
44
44
  paddingLeft: (header.depth - baseHeaderLevel) * 12,
45
45
  }}
46
+ {...{ 'data-depth': header.depth - baseHeaderLevel }}
46
47
  >
47
48
  <span
48
49
  className="rp-toc-item__text rp-doc"
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- export { matchPath } from '@rspress/runtime/server';
2
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';
3
2
  export { getSidebarDataGroup, normalizeHref, normalizePosixPath, RSPRESS_TEMP_DIR, removeTrailingSlash, withBase, } from '@rspress/shared';
4
3
  export { logger } from '@rspress/shared/logger';
5
4
  export { getIconUrlPath, getNodeAttribute, mergeDocConfig, } from '@rspress/shared/node-utils';
6
- export { defineConfig } from './cli/config';
7
- export { build, dev, remarkFileCodeBlock, remarkLink, serve } from './node';
8
- export type { CustomLinkMeta, DirSectionHeaderSideMeta, DirSideMeta, DividerSideMeta, FileSideMeta, MetaJson, NavJson, SectionHeaderMeta, SideMeta, SideMetaItem, } from './node/auto-nav-sidebar/type';
9
- export { PluginDriver } from './node/PluginDriver';
10
- export { RouteService } from './node/route/RouteService';
5
+ export { matchPath } from 'react-router-dom';
6
+ export { defineConfig } from './cli/config/index.js';
7
+ export { build, dev, remarkFileCodeBlock, remarkLink, serve } from './node/index.js';
8
+ export type { CustomLinkMeta, DirSectionHeaderSideMeta, DirSideMeta, DividerSideMeta, FileSideMeta, MetaJson, NavJson, SectionHeaderMeta, SideMeta, SideMetaItem, } from './node/auto-nav-sidebar/type.js';
9
+ export { PluginDriver } from './node/PluginDriver.js';
10
+ export { RouteService } from './node/route/RouteService.js';