@rspress/core 2.0.0-rc.5 → 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 (116) hide show
  1. package/dist/{0~7675.4468968d.js → 0~7675.d236b058.js} +3 -3
  2. package/dist/{5485.b9ce9bdf.js → 5485.7586c86a.js} +1 -1
  3. package/dist/{5341.9eb6b114.js → 7786.421b464f.js} +2 -2
  4. package/dist/{1820.985588a0.js → 9348.1beb3e25.js} +6 -0
  5. package/dist/cli/index.js +2 -2
  6. package/dist/config/defineConfig.d.ts +40 -0
  7. package/dist/{cli/config → config}/loadConfigFile.js +2 -2
  8. package/dist/eject-theme/components/Callout/index.scss +6 -6
  9. package/dist/eject-theme/components/DocContent/docComponents/title.tsx +21 -2
  10. package/dist/eject-theme/components/Llms/LlmsContainer.scss +6 -0
  11. package/dist/eject-theme/components/Llms/LlmsContainer.tsx +9 -0
  12. package/dist/eject-theme/components/Llms/LlmsCopyButton.scss +57 -0
  13. package/dist/eject-theme/components/Llms/LlmsCopyButton.tsx +94 -0
  14. package/dist/eject-theme/components/Llms/LlmsViewOptions.scss +98 -0
  15. package/dist/eject-theme/components/Llms/LlmsViewOptions.tsx +259 -0
  16. package/dist/eject-theme/components/Llms/index.scss +42 -0
  17. package/dist/eject-theme/components/Llms/index.tsx +4 -0
  18. package/dist/eject-theme/components/Llms/useMdUrl.ts +14 -0
  19. package/dist/eject-theme/components/Nav/index.scss +3 -0
  20. package/dist/eject-theme/components/Nav/index.tsx +7 -2
  21. package/dist/eject-theme/components/{Nav/NavTitle.tsx → NavTitle/index.tsx} +15 -6
  22. package/dist/index.d.ts +2 -1
  23. package/dist/index.js +3 -3
  24. package/dist/node/PluginDriver.js +1 -1
  25. package/dist/node/auto-nav-sidebar/index.js +1 -1
  26. package/dist/node/auto-nav-sidebar/normalize.js +1 -1
  27. package/dist/node/auto-nav-sidebar/utils.js +1 -1
  28. package/dist/node/auto-nav-sidebar/walk.js +1 -1
  29. package/dist/node/constants.js +1 -1
  30. package/dist/node/eject.js +1 -0
  31. package/dist/node/initRsbuild.js +5 -4
  32. package/dist/node/last-updated/index.js +1 -1
  33. package/dist/node/mdx/{loader.7c249a26.js → loader.15e0b2d2.js} +0 -5
  34. package/dist/node/mdx/options.js +2 -2
  35. package/dist/node/mdx/processor.js +1 -1
  36. package/dist/node/mdx/rehypePlugins/codeMeta.js +1 -1
  37. package/dist/node/mdx/rehypePlugins/headerAnchor.js +2 -3
  38. package/dist/node/mdx/rehypePlugins/shiki.js +1 -1
  39. package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +1 -2
  40. package/dist/node/mdx/remarkPlugins/image.js +1 -2
  41. package/dist/node/mdx/remarkPlugins/link.js +1 -2
  42. package/dist/node/mdx/remarkPlugins/toc.d.ts +4 -3
  43. package/dist/node/mdx/remarkPlugins/toc.js +14 -11
  44. package/dist/node/route/RoutePage.d.ts +3 -1
  45. package/dist/node/route/RoutePage.js +4 -0
  46. package/dist/node/route/RouteService.js +2 -2
  47. package/dist/node/route/extractPageData.d.ts +5 -0
  48. package/dist/node/route/extractPageData.js +88 -57
  49. package/dist/node/route/normalizeRoutePath.js +2 -2
  50. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.d.ts +21 -0
  51. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.js +21 -0
  52. package/dist/node/runtimeModule/i18n.js +4 -3
  53. package/dist/node/runtimeModule/pageData/createPageData.js +9 -6
  54. package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +20 -14
  55. package/dist/node/runtimeModule/siteData/createSiteData.js +2 -1
  56. package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
  57. package/dist/node/serve.js +1 -1
  58. package/dist/node/ssg/renderPage.js +1 -1
  59. package/dist/node/ssg/renderPageWorker.js +1 -1
  60. package/dist/node/ssg/renderPages.js +7 -3
  61. package/dist/node/ssg/rsbuildPluginSSG.js +1 -1
  62. package/dist/node/ssg/ssgEnv.js +1 -1
  63. package/dist/node/ssg-md/llms/emitLlmsTxt.js +2 -2
  64. package/dist/node/ssg-md/llms/llmsTxt.js +12 -2
  65. package/dist/node/ssg-md/remarkSplitMdx.js +2 -2
  66. package/dist/node/ssg-md/renderPage.js +1 -1
  67. package/dist/node/ssg-md/renderPages.js +1 -1
  68. package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -1
  69. package/dist/node/utils/createHash.js +1 -1
  70. package/dist/node/utils/flattenMdxContent.js +2 -2
  71. package/dist/node/utils/getPageKey.js +1 -1
  72. package/dist/node/utils/normalizePath.js +1 -1
  73. package/dist/node/utils/reactAlias.js +1 -1
  74. package/dist/runtime/hooks/useI18n.d.ts +1 -1
  75. package/dist/runtime/hooks/useI18n.js +2 -2
  76. package/dist/runtime/index.d.ts +1 -1
  77. package/dist/runtime/index.js +2 -2
  78. package/dist/runtime/utils.d.ts +2 -2
  79. package/dist/runtime/utils.js +2 -2
  80. package/dist/theme/components/Callout/index.css +6 -6
  81. package/dist/theme/components/DocContent/docComponents/title.js +25 -5
  82. package/dist/theme/components/HomeHero/index.css +10 -10
  83. package/dist/theme/components/Llms/LlmsContainer.css +7 -0
  84. package/dist/theme/components/Llms/LlmsContainer.d.ts +5 -0
  85. package/dist/theme/components/Llms/LlmsContainer.js +9 -0
  86. package/dist/theme/components/Llms/LlmsCopyButton.css +57 -0
  87. package/dist/theme/components/Llms/LlmsCopyButton.d.ts +20 -0
  88. package/dist/theme/components/Llms/LlmsCopyButton.js +73 -0
  89. package/dist/theme/components/Llms/LlmsCopyButton.js.LICENSE.txt +5 -0
  90. package/dist/theme/components/Llms/LlmsViewOptions.css +93 -0
  91. package/dist/theme/components/Llms/LlmsViewOptions.d.ts +34 -0
  92. package/dist/theme/components/Llms/LlmsViewOptions.js +206 -0
  93. package/dist/theme/components/Llms/LlmsViewOptions.js.LICENSE.txt +5 -0
  94. package/dist/theme/components/Llms/index.css +32 -0
  95. package/dist/theme/components/Llms/index.d.ts +4 -0
  96. package/dist/theme/components/Llms/index.js +5 -0
  97. package/dist/theme/components/Llms/useMdUrl.d.ts +6 -0
  98. package/dist/theme/components/Llms/useMdUrl.js +15 -0
  99. package/dist/theme/components/Nav/index.css +1 -0
  100. package/dist/theme/components/Nav/index.js +1 -2
  101. package/dist/theme/components/{Nav/NavTitle.d.ts → NavTitle/index.d.ts} +1 -1
  102. package/dist/theme/components/{Nav/NavTitle.js → NavTitle/index.js} +11 -6
  103. package/dist/theme/components/PageTabs/index.css +1 -1
  104. package/dist/theme/components/Tabs/index.css +4 -4
  105. package/dist/theme/hooks/useDynamicToc.d.ts +2 -0
  106. package/dist/theme/hooks/useDynamicToc.js +3 -1
  107. package/dist/theme/index.d.ts +2 -0
  108. package/dist/theme/index.js +3 -1
  109. package/dist/theme/layout/Layout/index.js +1 -1
  110. package/package.json +15 -16
  111. package/dist/8813.4b28f4bb.js +0 -1
  112. package/dist/cli/config/index.d.ts +0 -2
  113. /package/dist/{cli/config/index.js → config/defineConfig.js} +0 -0
  114. /package/dist/{cli/config → config}/loadConfigFile.d.ts +0 -0
  115. /package/dist/eject-theme/components/{Nav/NavTitle.scss → NavTitle/index.scss} +0 -0
  116. /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>}
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,11 +1,11 @@
1
1
  export { PluginDriver } from "./node/PluginDriver.js";
2
- export { RSPRESS_TEMP_DIR, getIconUrlPath, getNodeAttribute, getSidebarDataGroup, mergeDocConfig, normalizeHref, normalizePosixPath, removeTrailingSlash, withBase } from "./1820.985588a0.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
7
  export { logger } from "./6289.29817fb4.js";
8
- export { matchPath } from "./5341.9eb6b114.js";
8
+ export { matchPath } from "./7786.421b464f.js";
9
9
  export { remarkFileCodeBlock } from "./node/mdx/remarkPlugins/fileCodeBlock.js";
10
10
  export { remarkLink } from "./node/mdx/remarkPlugins/link.js";
11
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 "../1820.985588a0.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 "../../5341.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 "../../1820.985588a0.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 "../../1820.985588a0.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 "../../1820.985588a0.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.b9ce9bdf.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',
@@ -1,7 +1,7 @@
1
- import { createRequire, fileURLToPath, package_namespaceObject } from "../5485.b9ce9bdf.js";
1
+ import { createRequire, fileURLToPath, package_namespaceObject } from "../5485.7586c86a.js";
2
2
  import { node_path } from "../6289.29817fb4.js";
3
- import { removeTrailingSlash, MDX_OR_MD_REGEXP, cwd } from "../1820.985588a0.js";
4
- import { PLUGIN_REACT_NAME, pluginReact, pluginVirtualModule } from "../5341.9eb6b114.js";
3
+ import { removeTrailingSlash, MDX_OR_MD_REGEXP, cwd } from "../9348.1beb3e25.js";
4
+ import { PLUGIN_REACT_NAME, pluginReact, pluginVirtualModule } from "../7786.421b464f.js";
5
5
  import { createError } from "./utils/error.js";
6
6
  import { PUBLIC_DIR, CSR_CLIENT_ENTRY, SSR_CLIENT_ENTRY, OUTPUT_DIR, SSG_MD_SERVER_ENTRY, inlineThemeScript, NODE_SSG_BUNDLE_FOLDER, isProduction, PACKAGE_ROOT, SSR_SERVER_ENTRY, TEMPLATE_PATH, NODE_SSG_MD_BUNDLE_FOLDER, DEFAULT_THEME, NODE_SSG_MD_BUNDLE_NAME, DEFAULT_TITLE, NODE_SSG_BUNDLE_NAME } from "./constants.js";
7
7
  import { hintBuilderPluginsBreakingChange, hintThemeBreakingChange } from "./logger/hint.js";
@@ -151,7 +151,8 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
151
151
  PACKAGE_ROOT
152
152
  ],
153
153
  define: {
154
- 'process.env.TEST': JSON.stringify(process.env.TEST)
154
+ 'process.env.TEST': JSON.stringify(process.env.TEST),
155
+ 'process.env.ENABLE_LLMS_UI': JSON.stringify(Boolean(config.themeConfig?.llmsUI ?? config.llms))
155
156
  }
156
157
  },
157
158
  performance: {
@@ -1,4 +1,4 @@
1
- import { execa } from "../../0~7675.4468968d.js";
1
+ import { execa } from "../../0~7675.d236b058.js";
2
2
  function transform(timestamp, lang) {
3
3
  return new Date(timestamp).toLocaleString(lang || 'zh');
4
4
  }
@@ -1,12 +1,7 @@
1
1
  export { default as rehype } from "@shikijs/rehype";
2
2
  export { default as rehype_external_links } from "rehype-external-links";
3
3
  export { default as rehype_raw } from "rehype-raw";
4
- export { default as remark_gfm } from "remark-gfm";
5
4
  export { default as remark_mdx } from "remark-mdx";
6
- export { default as remark_stringify } from "remark-stringify";
7
- export { unified } from "unified";
8
- export { default as github_slugger } from "github-slugger";
9
5
  export { headingRank } from "hast-util-heading-rank";
10
6
  export { transformerAddLang, transformerAddLineNumbers, transformerAddTitle, transformerAddWrapCode } from "@rspress/core/shiki-transformers";
11
7
  export { createCssVariablesTheme } from "shiki";
12
- export { visitChildren } from "unist-util-visit-children";
@@ -1,6 +1,6 @@
1
1
  import { node_path } from "../../6289.29817fb4.js";
2
- import { nodeTypes } from "../../1820.985588a0.js";
3
- import { rehype_external_links, rehype_raw, remark_gfm, rehype } from "./loader.7c249a26.js";
2
+ import { remark_gfm, nodeTypes } from "../../9348.1beb3e25.js";
3
+ import { rehype, rehype_external_links, rehype_raw } from "./loader.15e0b2d2.js";
4
4
  import { remarkToc } from "./remarkPlugins/toc.js";
5
5
  import { remarkContainerSyntax } from "./remarkPlugins/containerSyntax.js";
6
6
  import { remarkFileCodeBlock } from "./remarkPlugins/fileCodeBlock.js";
@@ -1,5 +1,5 @@
1
1
  import { node_path } from "../../6289.29817fb4.js";
2
- import { createProcessor, loadFrontMatter, extractTextAndId } from "../../1820.985588a0.js";
2
+ import { createProcessor, loadFrontMatter, extractTextAndId } from "../../9348.1beb3e25.js";
3
3
  import { createMDXOptions } from "./options.js";
4
4
  import { applyReplaceRules } from "../utils/applyReplaceRules.js";
5
5
  import { escapeMarkdownHeadingIds } from "../utils/escapeHeadingIds.js";
@@ -1,4 +1,4 @@
1
- import { visit } from "../../../8813.4b28f4bb.js";
1
+ import { visit } from "../../../9348.1beb3e25.js";
2
2
  const rehypeCodeMeta = ()=>(tree)=>{
3
3
  visit(tree, 'element', (node)=>{
4
4
  if ('pre' === node.tagName && node.children[0]?.type === 'element' && 'code' === node.children[0].tagName) {
@@ -1,6 +1,5 @@
1
- import { extractTextAndId } from "../../../1820.985588a0.js";
2
- import { github_slugger, headingRank } from "../loader.7c249a26.js";
3
- import { visit } from "../../../8813.4b28f4bb.js";
1
+ import { visit, github_slugger, extractTextAndId } from "../../../9348.1beb3e25.js";
2
+ import { headingRank } from "../loader.15e0b2d2.js";
4
3
  const rehypeHeaderAnchor = ()=>{
5
4
  const slugger = new github_slugger();
6
5
  return (tree)=>{
@@ -1,4 +1,4 @@
1
- import { transformerAddLang, transformerAddLineNumbers, transformerAddTitle, createCssVariablesTheme, transformerAddWrapCode } from "../loader.7c249a26.js";
1
+ import { transformerAddLang, transformerAddLineNumbers, transformerAddTitle, createCssVariablesTheme, transformerAddWrapCode } from "../loader.15e0b2d2.js";
2
2
  const cssVariablesTheme = createCssVariablesTheme({
3
3
  name: 'css-variables',
4
4
  variablePrefix: '--shiki-',
@@ -1,6 +1,5 @@
1
1
  import { node_path, logger, picocolors, readFile } from "../../../6289.29817fb4.js";
2
- import { cwd } from "../../../1820.985588a0.js";
3
- import { visit } from "../../../8813.4b28f4bb.js";
2
+ import { visit, cwd } from "../../../9348.1beb3e25.js";
4
3
  import { createError } from "../../utils/error.js";
5
4
  const ERROR_PREFIX = '[remarkFileCodeBlock]';
6
5
  function parseFileFromMeta(meta) {
@@ -1,5 +1,4 @@
1
- import { isExternalUrl, getNodeAttribute } from "../../../1820.985588a0.js";
2
- import { visit } from "../../../8813.4b28f4bb.js";
1
+ import { isExternalUrl, getNodeAttribute, visit } from "../../../9348.1beb3e25.js";
3
2
  import { getDefaultImportAstNode } from "../../utils/getImportAstNode.js";
4
3
  const normalizeImageUrl = (imageUrl)=>{
5
4
  if (isExternalUrl(imageUrl) || imageUrl.startsWith('/')) return '';
@@ -1,6 +1,5 @@
1
1
  import { node_path, logger, picocolors } from "../../../6289.29817fb4.js";
2
- import { isExternalUrl, isProduction, addLeadingSlash, parseUrl, normalizeHref, withBase } from "../../../1820.985588a0.js";
3
- import { visit } from "../../../8813.4b28f4bb.js";
2
+ import { isExternalUrl, isProduction, addLeadingSlash, parseUrl, normalizeHref, visit, withBase } from "../../../9348.1beb3e25.js";
4
3
  import { hintRelativeMarkdownLink } from "../../logger/hint.js";
5
4
  import { createError } from "../../utils/error.js";
6
5
  function link_checkDeadLinks(checkDeadLinks, internalLinks, file, lint) {
@@ -1,12 +1,13 @@
1
- import type { Root } from 'hast';
1
+ import type { Root as HastRoot } from 'hast';
2
+ import type { Root as MdastRoot } from 'mdast';
2
3
  import type { Plugin } from 'unified';
3
4
  export interface TocItem {
4
5
  id: string;
5
6
  text: string;
6
7
  depth: number;
7
8
  }
8
- export declare const parseToc: (tree: Root) => {
9
+ export declare const parseToc: (tree: MdastRoot | HastRoot) => {
9
10
  title: string;
10
11
  toc: TocItem[];
11
12
  };
12
- export declare const remarkToc: Plugin<[], Root>;
13
+ export declare const remarkToc: Plugin<[], HastRoot>;