@rspress/core 2.0.0-rc.4 → 2.0.0-rc.6

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 (181) hide show
  1. package/dist/{0~7675.723d12b2.js → 0~7675.d236b058.js} +3 -3
  2. package/dist/{5485.9fc7f63d.js → 5485.7586c86a.js} +1 -1
  3. package/dist/{3521.9eb6b114.js → 7786.421b464f.js} +2 -2
  4. package/dist/9348.1beb3e25.js +11 -0
  5. package/dist/_private/react/render.js +1 -1
  6. package/dist/cli/index.js +2 -2
  7. package/dist/config/defineConfig.d.ts +40 -0
  8. package/dist/{cli/config → config}/loadConfigFile.js +2 -2
  9. package/dist/eject-theme/components/Callout/index.scss +6 -6
  10. package/dist/eject-theme/components/CodeBlock/index.tsx +1 -1
  11. package/dist/eject-theme/components/DocContent/docComponents/title.tsx +21 -2
  12. package/dist/eject-theme/components/FallbackHeading/index.tsx +4 -0
  13. package/dist/eject-theme/components/HomeBackground/useNavTransparent.tsx +2 -1
  14. package/dist/eject-theme/components/HomeHero/index.scss +8 -0
  15. package/dist/eject-theme/components/HomeHero/index.tsx +11 -2
  16. package/dist/eject-theme/components/Llms/LlmsContainer.scss +6 -0
  17. package/dist/eject-theme/components/Llms/LlmsContainer.tsx +9 -0
  18. package/dist/eject-theme/components/Llms/LlmsCopyButton.scss +57 -0
  19. package/dist/eject-theme/components/Llms/LlmsCopyButton.tsx +94 -0
  20. package/dist/eject-theme/components/Llms/LlmsViewOptions.scss +98 -0
  21. package/dist/eject-theme/components/Llms/LlmsViewOptions.tsx +259 -0
  22. package/dist/eject-theme/components/Llms/index.scss +42 -0
  23. package/dist/eject-theme/components/Llms/index.tsx +4 -0
  24. package/dist/eject-theme/components/Llms/useMdUrl.ts +14 -0
  25. package/dist/eject-theme/components/Nav/index.scss +3 -0
  26. package/dist/eject-theme/components/Nav/index.tsx +7 -2
  27. package/dist/eject-theme/components/{Nav/NavTitle.tsx → NavTitle/index.tsx} +15 -6
  28. package/dist/eject-theme/components/Overview/index.tsx +8 -62
  29. package/dist/eject-theme/components/OverviewGroup/index.tsx +46 -0
  30. package/dist/eject-theme/components/Steps/index.scss +1 -0
  31. package/dist/index.d.ts +2 -1
  32. package/dist/index.js +3 -4
  33. package/dist/node/PluginDriver.js +1 -1
  34. package/dist/node/auto-nav-sidebar/index.js +1 -1
  35. package/dist/node/auto-nav-sidebar/normalize.js +1 -1
  36. package/dist/node/auto-nav-sidebar/utils.js +1 -1
  37. package/dist/node/auto-nav-sidebar/walk.js +1 -1
  38. package/dist/node/constants.js +1 -1
  39. package/dist/node/eject.js +1 -0
  40. package/dist/node/initRsbuild.js +6 -6
  41. package/dist/node/last-updated/index.js +1 -1
  42. package/dist/node/mdx/{loader.7c249a26.js → loader.15e0b2d2.js} +0 -5
  43. package/dist/node/mdx/options.js +2 -2
  44. package/dist/node/mdx/processor.js +1 -1
  45. package/dist/node/mdx/rehypePlugins/codeMeta.js +1 -1
  46. package/dist/node/mdx/rehypePlugins/headerAnchor.js +2 -3
  47. package/dist/node/mdx/rehypePlugins/shiki.js +1 -1
  48. package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +1 -2
  49. package/dist/node/mdx/remarkPlugins/image.js +1 -3
  50. package/dist/node/mdx/remarkPlugins/link.js +1 -2
  51. package/dist/node/mdx/remarkPlugins/toc.d.ts +4 -3
  52. package/dist/node/mdx/remarkPlugins/toc.js +14 -11
  53. package/dist/node/route/RoutePage.d.ts +3 -1
  54. package/dist/node/route/RoutePage.js +4 -0
  55. package/dist/node/route/RouteService.js +2 -2
  56. package/dist/node/route/extractPageData.d.ts +5 -0
  57. package/dist/node/route/extractPageData.js +88 -58
  58. package/dist/node/route/normalizeRoutePath.js +2 -2
  59. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.d.ts +21 -0
  60. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.js +21 -0
  61. package/dist/node/runtimeModule/i18n.js +4 -3
  62. package/dist/node/runtimeModule/pageData/createPageData.js +9 -6
  63. package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +20 -14
  64. package/dist/node/runtimeModule/siteData/createSiteData.js +2 -1
  65. package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
  66. package/dist/node/serve.js +1 -1
  67. package/dist/node/ssg/renderPage.js +1 -1
  68. package/dist/node/ssg/renderPageWorker.js +1 -1
  69. package/dist/node/ssg/renderPages.js +7 -3
  70. package/dist/node/ssg/rsbuildPluginSSG.js +1 -1
  71. package/dist/node/ssg/ssgEnv.js +1 -1
  72. package/dist/node/ssg-md/llms/emitLlmsTxt.js +2 -2
  73. package/dist/node/ssg-md/llms/llmsTxt.js +12 -2
  74. package/dist/node/ssg-md/remarkSplitMdx.js +2 -2
  75. package/dist/node/ssg-md/renderPage.js +1 -1
  76. package/dist/node/ssg-md/renderPages.js +1 -1
  77. package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -1
  78. package/dist/node/utils/createHash.js +1 -1
  79. package/dist/node/utils/flattenMdxContent.js +2 -3
  80. package/dist/node/utils/getPageKey.js +1 -1
  81. package/dist/node/utils/normalizePath.js +1 -1
  82. package/dist/node/utils/reactAlias.js +1 -1
  83. package/dist/runtime/Content.d.ts +4 -0
  84. package/dist/runtime/Content.js +18 -0
  85. package/dist/runtime/NoSSR.d.ts +3 -0
  86. package/dist/runtime/NoSSR.js +14 -0
  87. package/dist/runtime/getSidebarDataGroup.test.js +68 -0
  88. package/dist/runtime/hooks/useActiveMatcher.d.ts +1 -0
  89. package/dist/runtime/hooks/useActiveMatcher.js +14 -0
  90. package/dist/runtime/hooks/useDark.d.ts +7 -0
  91. package/dist/runtime/hooks/useDark.js +7 -0
  92. package/dist/runtime/hooks/useFrontmatter.d.ts +4 -0
  93. package/dist/runtime/hooks/useFrontmatter.js +9 -0
  94. package/dist/runtime/hooks/useI18n.d.ts +2 -0
  95. package/dist/runtime/hooks/useI18n.js +14 -0
  96. package/dist/runtime/hooks/useLang.d.ts +1 -0
  97. package/dist/runtime/hooks/useLang.js +6 -0
  98. package/dist/runtime/hooks/useLocaleSiteData.d.ts +18 -0
  99. package/dist/runtime/hooks/useLocaleSiteData.js +20 -0
  100. package/dist/runtime/hooks/useNav.d.ts +1 -0
  101. package/dist/runtime/hooks/useNav.js +12 -0
  102. package/dist/runtime/hooks/usePage.d.ts +10 -0
  103. package/dist/runtime/hooks/usePage.js +9 -0
  104. package/dist/runtime/hooks/usePageData.d.ts +5 -0
  105. package/dist/runtime/hooks/usePageData.js +16 -0
  106. package/dist/runtime/hooks/usePages.d.ts +4 -0
  107. package/dist/runtime/hooks/usePages.js +7 -0
  108. package/dist/runtime/hooks/useSidebar.d.ts +16 -0
  109. package/dist/runtime/hooks/useSidebar.js +67 -0
  110. package/dist/runtime/hooks/useSite.d.ts +4 -0
  111. package/dist/runtime/hooks/useSite.js +7 -0
  112. package/dist/runtime/hooks/useVersion.d.ts +1 -0
  113. package/dist/runtime/hooks/useVersion.js +6 -0
  114. package/dist/runtime/hooks/useWindowSize.d.ts +9 -0
  115. package/dist/runtime/hooks/useWindowSize.js +31 -0
  116. package/dist/runtime/hooks/useWindowSize.test.js +36 -0
  117. package/dist/runtime/index.d.ts +21 -0
  118. package/dist/runtime/index.js +22 -0
  119. package/dist/runtime/route.d.ts +36 -0
  120. package/dist/runtime/route.js +53 -0
  121. package/dist/runtime/route.test.js +154 -0
  122. package/dist/runtime/ssrMdServerEntry.js +1 -1
  123. package/dist/runtime/utils.d.ts +12 -0
  124. package/dist/runtime/utils.js +34 -0
  125. package/dist/runtime/utils.test.js +34 -0
  126. package/dist/theme/components/Callout/index.css +6 -6
  127. package/dist/theme/components/CodeBlock/index.js +1 -1
  128. package/dist/theme/components/DocContent/docComponents/title.js +25 -5
  129. package/dist/theme/components/FallbackHeading/index.js +4 -1
  130. package/dist/theme/components/HomeBackground/useNavTransparent.js +1 -1
  131. package/dist/theme/components/HomeHero/index.css +16 -10
  132. package/dist/theme/components/HomeHero/index.js +10 -3
  133. package/dist/theme/components/Llms/LlmsContainer.css +7 -0
  134. package/dist/theme/components/Llms/LlmsContainer.d.ts +5 -0
  135. package/dist/theme/components/Llms/LlmsContainer.js +9 -0
  136. package/dist/theme/components/Llms/LlmsCopyButton.css +57 -0
  137. package/dist/theme/components/Llms/LlmsCopyButton.d.ts +20 -0
  138. package/dist/theme/components/Llms/LlmsCopyButton.js +73 -0
  139. package/dist/theme/components/Llms/LlmsCopyButton.js.LICENSE.txt +5 -0
  140. package/dist/theme/components/Llms/LlmsViewOptions.css +93 -0
  141. package/dist/theme/components/Llms/LlmsViewOptions.d.ts +34 -0
  142. package/dist/theme/components/Llms/LlmsViewOptions.js +206 -0
  143. package/dist/theme/components/Llms/LlmsViewOptions.js.LICENSE.txt +5 -0
  144. package/dist/theme/components/Llms/index.css +32 -0
  145. package/dist/theme/components/Llms/index.d.ts +4 -0
  146. package/dist/theme/components/Llms/index.js +5 -0
  147. package/dist/theme/components/Llms/useMdUrl.d.ts +6 -0
  148. package/dist/theme/components/Llms/useMdUrl.js +15 -0
  149. package/dist/theme/components/Nav/index.css +1 -0
  150. package/dist/theme/components/Nav/index.js +1 -2
  151. package/dist/theme/components/{Nav/NavTitle.d.ts → NavTitle/index.d.ts} +1 -1
  152. package/dist/theme/components/{Nav/NavTitle.js → NavTitle/index.js} +11 -6
  153. package/dist/theme/components/Overview/index.js +11 -43
  154. package/dist/theme/components/OverviewGroup/index.js +33 -0
  155. package/dist/theme/components/PageTabs/index.css +1 -1
  156. package/dist/theme/components/Steps/index.css +1 -0
  157. package/dist/theme/components/Tabs/index.css +4 -4
  158. package/dist/theme/hooks/useDynamicToc.d.ts +2 -0
  159. package/dist/theme/hooks/useDynamicToc.js +3 -1
  160. package/dist/theme/index.d.ts +3 -1
  161. package/dist/theme/index.js +4 -2
  162. package/dist/theme/layout/Layout/index.js +1 -1
  163. package/dist/theme/logic/useScrollAfterNav.js +2 -2
  164. package/dist/theme/logic/useScrollReset.js +2 -2
  165. package/dist/theme/logic/{useAppearance.d.ts → useThemeState.d.ts} +4 -1
  166. package/dist/theme/logic/useThemeState.js +50 -0
  167. package/dist/theme/styles/scrollbar.css +14 -2
  168. package/package.json +18 -20
  169. package/static/MediumZoom.tsx +1 -1
  170. package/dist/4669.69cb6b18.js +0 -1
  171. package/dist/8813.4b28f4bb.js +0 -1
  172. package/dist/9643.2dff683e.js +0 -4
  173. package/dist/cli/config/index.d.ts +0 -2
  174. package/dist/runtime.72d450ac.js +0 -1
  175. package/dist/runtime.d.ts +0 -2
  176. package/dist/runtime.js +0 -3
  177. package/dist/theme/logic/useAppearance.js +0 -64
  178. /package/dist/{cli/config/index.js → config/defineConfig.js} +0 -0
  179. /package/dist/{cli/config → config}/loadConfigFile.d.ts +0 -0
  180. /package/dist/eject-theme/components/{Nav/NavTitle.scss → NavTitle/index.scss} +0 -0
  181. /package/dist/theme/components/{Nav/NavTitle.css → NavTitle/index.css} +0 -0
@@ -0,0 +1,259 @@
1
+ /**
2
+ * Inspired from fumadocs docsite
3
+ * @from https://github.com/fuma-nama/fumadocs/blob/5723bbe58ef805a5421a780abf235a10b251be2f/apps/docs/app/docs/%5B...slug%5D/page.client.tsx#L11
4
+ * @license MIT
5
+ */
6
+ import { useI18n, useSite } from '@rspress/core/runtime';
7
+ import { IconDown } from '@theme';
8
+ import type React from 'react';
9
+ import { useEffect, useMemo, useRef, useState } from 'react';
10
+ import './index.scss';
11
+ import './LlmsViewOptions.scss';
12
+ import { useMdUrl } from './useMdUrl';
13
+
14
+ type Option =
15
+ | {
16
+ title: string;
17
+ icon?: React.ReactNode;
18
+ onClick?: () => void;
19
+ }
20
+ | {
21
+ title: string;
22
+ href: string;
23
+ icon?: React.ReactNode;
24
+ }
25
+ | 'markdownLink'
26
+ | 'chatgpt'
27
+ | 'claude';
28
+
29
+ export interface LlmsViewOptionsProps
30
+ extends React.ButtonHTMLAttributes<HTMLButtonElement> {
31
+ /**
32
+ * Default options for the dropdown.
33
+ * @default ['markdownLink', 'chatgpt', 'claude']
34
+ * - 'chatgpt': Open in ChatGPT
35
+ * - 'claude': Open in Claude
36
+ */
37
+ options?: Option[];
38
+ /**
39
+ * Button text by language, used with `useLang`.
40
+ * @default en: 'Open', zh: '\u6253\u5f00'
41
+ */
42
+ textByLang?: Record<string, string>;
43
+ /**
44
+ * Button text.
45
+ * Priority is higher than textByLang
46
+ * @default ''
47
+ */
48
+ text?: string;
49
+ }
50
+
51
+ const IconExternalLink = () => {
52
+ return (
53
+ <svg
54
+ xmlns="http://www.w3.org/2000/svg"
55
+ width="16"
56
+ height="16"
57
+ viewBox="0 0 16 16"
58
+ fill="none"
59
+ >
60
+ <path
61
+ d="M9.33301 2H13.9997V6.66667"
62
+ stroke="currentColor"
63
+ strokeWidth="1.33333"
64
+ strokeLinecap="round"
65
+ strokeLinejoin="round"
66
+ />
67
+ <path
68
+ d="M14 9.82457V13C14 13.5523 13.5523 14 13 14H3C2.44772 14 2 13.5523 2 13V3C2 2.44772 2.44772 2 3 2H6"
69
+ stroke="currentColor"
70
+ strokeWidth="1.33333"
71
+ strokeLinecap="round"
72
+ strokeLinejoin="round"
73
+ />
74
+ <path
75
+ d="M8.59961 7.39996L13.6996 2.29996"
76
+ stroke="currentColor"
77
+ strokeWidth="1.33333"
78
+ strokeLinecap="round"
79
+ strokeLinejoin="round"
80
+ />
81
+ </svg>
82
+ );
83
+ };
84
+
85
+ const DEFAULT_OPTIONS: Option[] = ['markdownLink', 'chatgpt', 'claude'];
86
+
87
+ export function LlmsViewOptions({
88
+ options: propsOptions,
89
+ }: LlmsViewOptionsProps) {
90
+ const { site } = useSite();
91
+ const llmsUI = site?.themeConfig?.llmsUI;
92
+ const options =
93
+ (typeof llmsUI === 'object' ? llmsUI?.viewOptions : propsOptions) ??
94
+ DEFAULT_OPTIONS;
95
+ const [isOpen, setIsOpen] = useState(false);
96
+ const dropdownRef = useRef<HTMLButtonElement>(null);
97
+
98
+ useEffect(() => {
99
+ const handleClickOutside = (event: MouseEvent) => {
100
+ if (
101
+ dropdownRef.current &&
102
+ event.target &&
103
+ !dropdownRef.current.contains(event.target as Node)
104
+ ) {
105
+ setIsOpen(false);
106
+ }
107
+ };
108
+
109
+ document.addEventListener('mousedown', handleClickOutside);
110
+ return () => {
111
+ document.removeEventListener('mousedown', handleClickOutside);
112
+ };
113
+ }, []);
114
+
115
+ const toggleDropdown = () => {
116
+ setIsOpen(!isOpen);
117
+ };
118
+
119
+ const { pathname } = useMdUrl();
120
+ const t = useI18n();
121
+
122
+ const items = useMemo(() => {
123
+ const fullMarkdownUrl =
124
+ typeof window !== 'undefined'
125
+ ? new URL(pathname, window.location.origin).toString()
126
+ : 'loading';
127
+ const q = `Read ${fullMarkdownUrl}, I want to ask questions about it.`;
128
+
129
+ return {
130
+ markdownLink: {
131
+ title: t('copyMarkdownLinkText'),
132
+ icon: (
133
+ <svg
134
+ xmlns="http://www.w3.org/2000/svg"
135
+ viewBox="0 0 24 24"
136
+ width="24"
137
+ height="24"
138
+ >
139
+ <g
140
+ fill="none"
141
+ stroke="currentColor"
142
+ strokeLinecap="round"
143
+ strokeLinejoin="round"
144
+ strokeWidth="2"
145
+ >
146
+ <path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" />
147
+ <path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" />
148
+ </g>
149
+ </svg>
150
+ ),
151
+ onClick: () => {
152
+ navigator.clipboard.writeText(fullMarkdownUrl);
153
+ },
154
+ },
155
+ chatgpt: {
156
+ title: t('openInText', { name: 'ChatGPT' }),
157
+ href: `https://chatgpt.com/?${new URLSearchParams({
158
+ hints: 'search',
159
+ q,
160
+ })}`,
161
+ icon: (
162
+ <svg
163
+ role="img"
164
+ viewBox="0 0 24 24"
165
+ fill="currentColor"
166
+ xmlns="http://www.w3.org/2000/svg"
167
+ >
168
+ <title>OpenAI</title>
169
+ <path d="M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z" />
170
+ <path d="M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z" />
171
+ </svg>
172
+ ),
173
+ },
174
+ claude: {
175
+ title: t('openInText', { name: 'Claude' }),
176
+ href: `https://claude.ai/new?${new URLSearchParams({
177
+ q,
178
+ })}`,
179
+ icon: (
180
+ <svg
181
+ fill="currentColor"
182
+ role="img"
183
+ viewBox="0 0 24 24"
184
+ xmlns="http://www.w3.org/2000/svg"
185
+ >
186
+ <title>Anthropic</title>
187
+ <path d="M17.3041 3.541h-3.6718l6.696 16.918H24Zm-10.6082 0L0 20.459h3.7442l1.3693-3.5527h7.0052l1.3693 3.5528h3.7442L10.5363 3.5409Zm-.3712 10.2232 2.2914-5.9456 2.2914 5.9456Z" />
188
+ </svg>
189
+ ),
190
+ },
191
+ };
192
+ }, [pathname, t]);
193
+
194
+ return (
195
+ <>
196
+ <button
197
+ ref={dropdownRef}
198
+ onClick={toggleDropdown}
199
+ className={`rp-llms-button rp-llms-view-options__trigger ${
200
+ isOpen ? 'rp-llms-view-options__trigger--active' : ''
201
+ }`}
202
+ >
203
+ <IconDown
204
+ className={`rp-llms-view-options__arrow ${isOpen ? 'rp-llms-view-options__arrow--rotated' : ''}`}
205
+ />
206
+ {isOpen && (
207
+ <div className="rp-llms-view-options__menu">
208
+ {options.map(item => {
209
+ let displayItem = item as {
210
+ title: string;
211
+ href?: string;
212
+ icon?: React.ReactNode;
213
+ onClick?: () => void;
214
+ };
215
+ if (item === 'markdownLink') {
216
+ displayItem = items.markdownLink;
217
+ } else if (item === 'chatgpt') {
218
+ displayItem = items.chatgpt;
219
+ } else if (item === 'claude') {
220
+ displayItem = items.claude;
221
+ }
222
+ if (displayItem.href) {
223
+ return (
224
+ <a
225
+ key={displayItem.title}
226
+ className="rp-llms-view-options__menu-item"
227
+ href={displayItem.href}
228
+ target="_blank"
229
+ rel="noopener noreferrer"
230
+ >
231
+ <span className="rp-llms-view-options__item-icon">
232
+ {displayItem.icon}
233
+ </span>
234
+ <span>{displayItem.title}</span>
235
+ <span className="rp-llms-view-options__external-icon">
236
+ <IconExternalLink />
237
+ </span>
238
+ </a>
239
+ );
240
+ }
241
+ return (
242
+ <div
243
+ key={displayItem.title}
244
+ className="rp-llms-view-options__menu-item"
245
+ onClick={displayItem.onClick}
246
+ >
247
+ <span className="rp-llms-view-options__item-icon">
248
+ {displayItem.icon}
249
+ </span>
250
+ <span>{displayItem.title}</span>
251
+ </div>
252
+ );
253
+ })}
254
+ </div>
255
+ )}
256
+ </button>
257
+ </>
258
+ );
259
+ }
@@ -0,0 +1,42 @@
1
+ .rp-llms-button {
2
+ display: inline-flex;
3
+ justify-content: center;
4
+ align-items: center;
5
+ height: 36px;
6
+ padding: 0 12px;
7
+ gap: 6px;
8
+
9
+ border-radius: 8px;
10
+ border: 1px solid var(--rp-c-divider-light);
11
+ background: var(--rp-c-bg);
12
+ color: var(--rp-c-text-2);
13
+
14
+ font-size: 14px;
15
+ font-weight: 500;
16
+ line-height: normal;
17
+
18
+ user-select: none;
19
+ white-space: nowrap;
20
+
21
+ transition:
22
+ background 0.2s,
23
+ border-color 0.2s,
24
+ color 0.2s,
25
+ box-shadow 0.2s,
26
+ transform 0.1s,
27
+ opacity 0.2s;
28
+
29
+ cursor: pointer;
30
+
31
+ &:hover {
32
+ background: var(--rp-c-bg-soft);
33
+ border-color: var(--rp-c-divider);
34
+ color: var(--rp-c-text-1);
35
+ box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
36
+ }
37
+
38
+ &:active {
39
+ background: var(--rp-c-bg-soft);
40
+ box-shadow: none;
41
+ }
42
+ }
@@ -0,0 +1,4 @@
1
+ export { LlmsContainer, type LlmsContainerProps } from './LlmsContainer';
2
+ export { LlmsCopyButton, type LlmsCopyButtonProps } from './LlmsCopyButton';
3
+ export { LlmsViewOptions, type LlmsViewOptionsProps } from './LlmsViewOptions';
4
+ export { useMdUrl } from './useMdUrl';
@@ -0,0 +1,14 @@
1
+ import { routePathToMdPath, usePageData } from '@rspress/core/runtime';
2
+ import { useMemo } from 'react';
3
+
4
+ /**
5
+ * @private
6
+ */
7
+ export function useMdUrl(): { pathname: string } {
8
+ const { page } = usePageData();
9
+ const mdPath = useMemo(() => {
10
+ const pathname = routePathToMdPath(page.routePath);
11
+ return { pathname };
12
+ }, [page.routePath]);
13
+ return mdPath;
14
+ }
@@ -1,4 +1,7 @@
1
1
  .rp-nav {
2
+ transition:
3
+ background-color 0.2s ease-in-out,
4
+ border-bottom 0.2s ease-in-out;
2
5
  display: flex;
3
6
  height: var(--rp-nav-height);
4
7
  flex-shrink: 0;
@@ -1,8 +1,13 @@
1
1
  import { useNav } from '@rspress/core/runtime';
2
- import { NavHamburger, Search, SocialLinks, SwitchAppearance } from '@theme';
2
+ import {
3
+ NavHamburger,
4
+ NavTitle,
5
+ Search,
6
+ SocialLinks,
7
+ SwitchAppearance,
8
+ } from '@theme';
3
9
  import './index.scss';
4
10
  import { NavLangs, NavMenu, NavMenuDivider, NavVersions } from './NavMenu';
5
- import { NavTitle } from './NavTitle';
6
11
 
7
12
  export interface NavProps {
8
13
  beforeNavTitle?: React.ReactNode;
@@ -1,18 +1,27 @@
1
1
  import {
2
2
  addLeadingSlash,
3
+ addTrailingSlash,
3
4
  normalizeImagePath,
4
- useLocaleSiteData,
5
+ useLang,
5
6
  useSite,
6
7
  } from '@rspress/core/runtime';
7
8
  import { Link } from '@theme';
8
9
  import { useMemo } from 'react';
9
- import './NavTitle.scss';
10
+ import './index.scss';
10
11
 
11
12
  export const NavTitle = () => {
12
13
  const { site } = useSite();
13
- const localeData = useLocaleSiteData();
14
- const { logo: rawLogo, logoText } = site;
15
- const title = (localeData.title ?? site.title) || 'Home';
14
+ const lang = useLang();
15
+
16
+ const themeConfig = site?.themeConfig ?? {};
17
+ const defaultLang = site.lang ?? '';
18
+ const locales = themeConfig?.locales;
19
+ const localeInfo = locales?.find(locale => locale.lang === lang);
20
+
21
+ const title = (localeInfo?.title ?? site.title) || 'Home';
22
+ const langRoutePrefix = lang === defaultLang ? '/' : addTrailingSlash(lang);
23
+
24
+ const { logo: rawLogo, logoText, logoHref } = site;
16
25
  const logo = useMemo(() => {
17
26
  if (!rawLogo) {
18
27
  return null;
@@ -48,7 +57,7 @@ export const NavTitle = () => {
48
57
  return (
49
58
  <div className="rp-nav__title">
50
59
  <Link
51
- href={addLeadingSlash((localeData as any).langRoutePrefix ?? '/')}
60
+ href={logoHref || addLeadingSlash(langRoutePrefix)}
52
61
  className="rp-nav__title__link"
53
62
  >
54
63
  {logo && <div className="rp-nav__title__logo">{logo}</div>}
@@ -6,11 +6,9 @@ import type {
6
6
  } from '@rspress/core';
7
7
  import {
8
8
  isEqualPath,
9
- normalizeHref,
10
9
  useI18n,
11
10
  usePageData,
12
11
  useSidebar,
13
- withBase,
14
12
  } from '@rspress/core/runtime';
15
13
  import {
16
14
  FallbackHeading,
@@ -27,65 +25,6 @@ import {
27
25
  import './index.scss';
28
26
  import { findItemByRoutePath } from './utils';
29
27
 
30
- function routePathToMdPath(routePath: string): string {
31
- let url: string = routePath;
32
- url = normalizeHref(url, false);
33
- url = url.replace(/\.html$/, '.md');
34
- return withBase(url);
35
- }
36
-
37
- function OverviewMarkdown({
38
- title,
39
- groups,
40
- }: {
41
- title: string;
42
- groups: Group[];
43
- }) {
44
- const lines: string[] = [];
45
-
46
- lines.push(`# ${title}`);
47
- lines.push('');
48
-
49
- for (const group of groups) {
50
- if (group.name) {
51
- lines.push(`## ${group.name}`);
52
- lines.push('');
53
- }
54
-
55
- for (const item of group.items) {
56
- const itemTitle = item.link
57
- ? `[${item.text}](${routePathToMdPath(item.link)})`
58
- : `**${item.text}**`;
59
- lines.push(`### ${itemTitle}`);
60
- lines.push('');
61
-
62
- // Render headers as a list
63
- if (item.headers && item.headers.length > 0) {
64
- for (const header of item.headers) {
65
- const headerLink = item.link
66
- ? `[${header.text}](${routePathToMdPath(item.link)}#${header.id})`
67
- : header.text;
68
- lines.push(`- ${headerLink}`);
69
- }
70
- lines.push('');
71
- }
72
-
73
- // Render custom items as a list
74
- if (item.items && item.items.length > 0) {
75
- for (const subItem of item.items) {
76
- const subItemLink = subItem.link
77
- ? `[${subItem.text}](${routePathToMdPath(subItem.link)})`
78
- : subItem.text;
79
- lines.push(`- ${subItemLink}`);
80
- }
81
- lines.push('');
82
- }
83
- }
84
- }
85
-
86
- return <>{lines.join('\n')}</>;
87
- }
88
-
89
28
  // Utility function to normalize text for search
90
29
  const normalizeText = (s: string) => s.toLowerCase().replace(/-/g, ' ');
91
30
 
@@ -302,7 +241,14 @@ export function Overview(props: {
302
241
  const overviewTitle = title || 'Overview';
303
242
 
304
243
  if (process.env.__SSR_MD__) {
305
- return <OverviewMarkdown title={overviewTitle} groups={groups} />;
244
+ return (
245
+ <>
246
+ <FallbackHeading level={1} title={overviewTitle} />
247
+ {groups.map(group => (
248
+ <OverviewGroup key={group?.name} group={group} />
249
+ ))}
250
+ </>
251
+ );
306
252
  }
307
253
 
308
254
  return (
@@ -1,10 +1,52 @@
1
1
  import { Link, renderInlineMarkdown } from '@theme';
2
2
  import './index.scss';
3
3
  import type { Header } from '@rspress/core';
4
+ import { routePathToMdPath } from '@rspress/core/runtime';
4
5
  import { FallbackHeading, SvgWrapper } from '@theme';
5
6
  import { useMemo } from 'react';
6
7
  import IconPlugin from './icons/plugin.svg';
7
8
 
9
+ function OverviewGroupMarkdown({ group }: { group: Group }) {
10
+ const lines: string[] = [];
11
+
12
+ if (group.name) {
13
+ lines.push(`## ${group.name}`);
14
+ lines.push('');
15
+ }
16
+
17
+ for (const item of group.items) {
18
+ const itemTitle = item.link
19
+ ? `[${item.text}](${routePathToMdPath(item.link)})`
20
+ : `**${item.text}**`;
21
+ lines.push(`### ${itemTitle}`);
22
+ lines.push('');
23
+
24
+ // Render headers as a list
25
+ if (item.headers && item.headers.length > 0) {
26
+ for (const header of item.headers) {
27
+ const headerLink = item.link
28
+ ? `[${header.text}](${routePathToMdPath(item.link)}#${header.id})`
29
+ : header.text;
30
+ lines.push(`- ${headerLink}`);
31
+ }
32
+ lines.push('');
33
+ }
34
+
35
+ // Render custom items as a list
36
+ if (item.items && item.items.length > 0) {
37
+ for (const subItem of item.items) {
38
+ const subItemLink = subItem.link
39
+ ? `[${subItem.text}](${routePathToMdPath(subItem.link)})`
40
+ : subItem.text;
41
+ lines.push(`- ${subItemLink}`);
42
+ }
43
+ lines.push('');
44
+ }
45
+ }
46
+
47
+ return <>{lines.join('\n')}</>;
48
+ }
49
+
8
50
  export interface GroupItem {
9
51
  text: string;
10
52
  link: string;
@@ -20,6 +62,10 @@ export interface Group {
20
62
  }
21
63
 
22
64
  export const OverviewGroup = ({ group }: { group: Group }) => {
65
+ if (process.env.__SSR_MD__) {
66
+ return <OverviewGroupMarkdown group={group} />;
67
+ }
68
+
23
69
  const { itemsWithContent, itemsWithoutContent } = useMemo(() => {
24
70
  // Separate items into those with content and those without
25
71
  const itemsWithContent = group.items.filter(
@@ -21,6 +21,7 @@
21
21
  justify-content: center;
22
22
  font-size: 1.1rem;
23
23
  font-weight: 400;
24
+ line-height: 30px;
24
25
  color: var(--rp-c-text-1);
25
26
  background-color: var(--rp-code-block-bg);
26
27
  border: 1.5px solid var(--rp-c-text-3);
package/dist/index.d.ts CHANGED
@@ -3,7 +3,8 @@ export { getSidebarDataGroup, normalizeHref, normalizePosixPath, RSPRESS_TEMP_DI
3
3
  export { logger } from '@rspress/shared/logger';
4
4
  export { getIconUrlPath, getNodeAttribute, mergeDocConfig, } from '@rspress/shared/node-utils';
5
5
  export { matchPath } from 'react-router-dom';
6
- export { defineConfig } from './cli/config/index.js';
6
+ export type { UserConfigAsyncFn } from './config/defineConfig.js';
7
+ export { defineConfig } from './config/defineConfig.js';
7
8
  export { build, dev, remarkFileCodeBlock, remarkLink, serve } from './node/index.js';
8
9
  export type { CustomLinkMeta, DirSectionHeaderSideMeta, DirSideMeta, DividerSideMeta, FileSideMeta, MetaJson, NavJson, SectionHeaderMeta, SideMeta, SideMetaItem, } from './node/auto-nav-sidebar/type.js';
9
10
  export { PluginDriver } from './node/PluginDriver.js';
package/dist/index.js CHANGED
@@ -1,12 +1,11 @@
1
1
  export { PluginDriver } from "./node/PluginDriver.js";
2
- export { RSPRESS_TEMP_DIR, getSidebarDataGroup, normalizeHref, normalizePosixPath, removeTrailingSlash, withBase } from "./4669.69cb6b18.js";
2
+ export { RSPRESS_TEMP_DIR, getIconUrlPath, getNodeAttribute, getSidebarDataGroup, mergeDocConfig, normalizeHref, normalizePosixPath, removeTrailingSlash, withBase } from "./9348.1beb3e25.js";
3
3
  export { RouteService } from "./node/route/RouteService.js";
4
4
  export { build } from "./node/build.js";
5
- export { defineConfig } from "./cli/config/index.js";
5
+ export { defineConfig } from "./config/defineConfig.js";
6
6
  export { dev } from "./node/dev.js";
7
- export { getIconUrlPath, getNodeAttribute, mergeDocConfig } from "./9643.2dff683e.js";
8
7
  export { logger } from "./6289.29817fb4.js";
9
- export { matchPath } from "./3521.9eb6b114.js";
8
+ export { matchPath } from "./7786.421b464f.js";
10
9
  export { remarkFileCodeBlock } from "./node/mdx/remarkPlugins/fileCodeBlock.js";
11
10
  export { remarkLink } from "./node/mdx/remarkPlugins/link.js";
12
11
  export { serve } from "./node/serve.js";
@@ -1,5 +1,5 @@
1
1
  import { node_path } from "../6289.29817fb4.js";
2
- import { addTrailingSlash, addLeadingSlash } from "../4669.69cb6b18.js";
2
+ import { addTrailingSlash, addLeadingSlash } from "../9348.1beb3e25.js";
3
3
  import { createError } from "./utils/error.js";
4
4
  import { auto_nav_sidebar_haveNavSidebarConfig } from "./auto-nav-sidebar/index.js";
5
5
  class PluginDriver {
@@ -1,5 +1,5 @@
1
1
  import { node_path } from "../../6289.29817fb4.js";
2
- import { DEFAULT_PAGE_EXTENSIONS } from "../../3521.9eb6b114.js";
2
+ import { DEFAULT_PAGE_EXTENSIONS } from "../../7786.421b464f.js";
3
3
  import { processLocales, combineWalkResult } from "./locales.js";
4
4
  import { walk } from "./walk.js";
5
5
  async function runAutoNavSide(config, metaFileSet, mdFileSet) {
@@ -1,5 +1,5 @@
1
1
  import { readdir, extname, stat as promises_stat, relative, logger, join, picocolors } from "../../6289.29817fb4.js";
2
- import { isExternalUrl, slash } from "../../4669.69cb6b18.js";
2
+ import { isExternalUrl, slash } from "../../9348.1beb3e25.js";
3
3
  import { createError } from "../utils/error.js";
4
4
  import { PUBLIC_DIR } from "../constants.js";
5
5
  import { pathExists, extractInfoFromFrontmatterWithAbsolutePath, readJson } from "./utils.js";
@@ -1,5 +1,5 @@
1
1
  import { node_path, promises } from "../../6289.29817fb4.js";
2
- import { loadFrontMatter, extractTextAndId } from "../../9643.2dff683e.js";
2
+ import { loadFrontMatter, extractTextAndId } from "../../9348.1beb3e25.js";
3
3
  async function pathExists(path) {
4
4
  try {
5
5
  await promises.access(path);
@@ -1,5 +1,5 @@
1
1
  import { node_path, promises } from "../../6289.29817fb4.js";
2
- import { isExternalUrl } from "../../4669.69cb6b18.js";
2
+ import { isExternalUrl } from "../../9348.1beb3e25.js";
3
3
  import { pathExists } from "../utils/fs.js";
4
4
  import { readJson } from "./utils.js";
5
5
  import { createError } from "../utils/error.js";
@@ -1,4 +1,4 @@
1
- import { createRequire, package_namespaceObject } from "../5485.9fc7f63d.js";
1
+ import { createRequire, package_namespaceObject } from "../5485.7586c86a.js";
2
2
  import { node_path } from "../6289.29817fb4.js";
3
3
  const constants_require = createRequire(import.meta.url);
4
4
  const RSPRESS_VERSION = package_namespaceObject.rE;
@@ -16,6 +16,7 @@ async function getAvailableComponents() {
16
16
  'HomeHero',
17
17
  'HomeBackground',
18
18
  'HomeFooter',
19
+ 'NavTitle',
19
20
  'SourceCode',
20
21
  'Toc',
21
22
  'Tabs',