@rspress/core 2.0.0-rc.5 → 2.0.0-rc.7

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 (135) hide show
  1. package/dist/{0~7675.4468968d.js → 0~7675.efbf8813.js} +3 -3
  2. package/dist/{5485.b9ce9bdf.js → 5485.e8bfcd99.js} +1 -1
  3. package/dist/{1820.985588a0.js → 9348.1beb3e25.js} +6 -0
  4. package/dist/{5341.9eb6b114.js → 9446.421b464f.js} +2 -2
  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/HomeFeature/index.scss +6 -0
  11. package/dist/eject-theme/components/HomeFeature/index.tsx +5 -6
  12. package/dist/eject-theme/components/Llms/LlmsContainer.scss +6 -0
  13. package/dist/eject-theme/components/Llms/LlmsContainer.tsx +9 -0
  14. package/dist/eject-theme/components/Llms/LlmsCopyButton.scss +57 -0
  15. package/dist/eject-theme/components/Llms/LlmsCopyButton.tsx +101 -0
  16. package/dist/eject-theme/components/Llms/LlmsViewOptions.scss +98 -0
  17. package/dist/eject-theme/components/Llms/LlmsViewOptions.tsx +209 -0
  18. package/dist/eject-theme/components/Llms/index.scss +42 -0
  19. package/dist/eject-theme/components/Llms/index.tsx +4 -0
  20. package/dist/eject-theme/components/Llms/useMdUrl.ts +14 -0
  21. package/dist/eject-theme/components/Nav/index.scss +3 -0
  22. package/dist/eject-theme/components/Nav/index.tsx +7 -2
  23. package/dist/eject-theme/components/{Nav/NavTitle.tsx → NavTitle/index.tsx} +15 -6
  24. package/dist/eject-theme/components/Overview/index.tsx +3 -1
  25. package/dist/eject-theme/components/OverviewGroup/index.tsx +1 -1
  26. package/dist/eject-theme/components/SvgWrapper/index.tsx +41 -7
  27. package/dist/index.d.ts +2 -1
  28. package/dist/index.js +3 -3
  29. package/dist/node/PluginDriver.js +1 -1
  30. package/dist/node/auto-nav-sidebar/index.js +1 -1
  31. package/dist/node/auto-nav-sidebar/normalize.js +1 -1
  32. package/dist/node/auto-nav-sidebar/utils.js +1 -1
  33. package/dist/node/auto-nav-sidebar/walk.js +1 -1
  34. package/dist/node/constants.js +1 -1
  35. package/dist/node/eject.js +1 -0
  36. package/dist/node/initRsbuild.js +14 -4
  37. package/dist/node/last-updated/index.js +1 -1
  38. package/dist/node/mdx/{loader.7c249a26.js → loader.15e0b2d2.js} +0 -5
  39. package/dist/node/mdx/options.js +2 -2
  40. package/dist/node/mdx/processor.js +1 -1
  41. package/dist/node/mdx/rehypePlugins/codeMeta.js +1 -1
  42. package/dist/node/mdx/rehypePlugins/headerAnchor.js +2 -3
  43. package/dist/node/mdx/rehypePlugins/shiki.js +1 -1
  44. package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +1 -2
  45. package/dist/node/mdx/remarkPlugins/image.js +1 -2
  46. package/dist/node/mdx/remarkPlugins/link.js +1 -2
  47. package/dist/node/mdx/remarkPlugins/toc.d.ts +4 -3
  48. package/dist/node/mdx/remarkPlugins/toc.js +14 -11
  49. package/dist/node/route/RoutePage.d.ts +3 -1
  50. package/dist/node/route/RoutePage.js +4 -0
  51. package/dist/node/route/RouteService.js +2 -2
  52. package/dist/node/route/extractPageData.d.ts +5 -0
  53. package/dist/node/route/extractPageData.js +88 -57
  54. package/dist/node/route/normalizeRoutePath.js +2 -2
  55. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.d.ts +21 -0
  56. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.js +21 -0
  57. package/dist/node/runtimeModule/i18n.js +4 -3
  58. package/dist/node/runtimeModule/pageData/createPageData.js +9 -6
  59. package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +20 -14
  60. package/dist/node/runtimeModule/siteData/createSiteData.js +2 -1
  61. package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
  62. package/dist/node/serve.js +1 -1
  63. package/dist/node/ssg/renderPage.js +1 -1
  64. package/dist/node/ssg/renderPageWorker.js +1 -1
  65. package/dist/node/ssg/renderPages.js +7 -3
  66. package/dist/node/ssg/rsbuildPluginSSG.js +1 -1
  67. package/dist/node/ssg/ssgEnv.js +1 -1
  68. package/dist/node/ssg-md/llms/emitLlmsTxt.js +2 -2
  69. package/dist/node/ssg-md/llms/llmsTxt.js +12 -2
  70. package/dist/node/ssg-md/remarkSplitMdx.js +2 -2
  71. package/dist/node/ssg-md/renderPage.js +1 -1
  72. package/dist/node/ssg-md/renderPages.js +1 -1
  73. package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -1
  74. package/dist/node/utils/createHash.js +1 -1
  75. package/dist/node/utils/flattenMdxContent.js +2 -2
  76. package/dist/node/utils/getPageKey.js +1 -1
  77. package/dist/node/utils/normalizePath.js +1 -1
  78. package/dist/node/utils/reactAlias.js +1 -1
  79. package/dist/runtime/hooks/useI18n.d.ts +1 -1
  80. package/dist/runtime/hooks/useI18n.js +2 -2
  81. package/dist/runtime/hooks/usePageData.d.ts +1 -0
  82. package/dist/runtime/index.d.ts +1 -1
  83. package/dist/runtime/index.js +2 -2
  84. package/dist/runtime/utils.d.ts +2 -2
  85. package/dist/runtime/utils.js +2 -2
  86. package/dist/theme/assets/external-link.js +16 -0
  87. package/dist/theme/assets/link.js +26 -0
  88. package/dist/theme/components/Callout/index.css +6 -6
  89. package/dist/theme/components/DocContent/docComponents/title.js +25 -5
  90. package/dist/theme/components/HomeFeature/index.css +5 -0
  91. package/dist/theme/components/HomeFeature/index.js +4 -2
  92. package/dist/theme/components/HomeHero/index.css +10 -10
  93. package/dist/theme/components/Llms/LlmsContainer.css +7 -0
  94. package/dist/theme/components/Llms/LlmsContainer.d.ts +5 -0
  95. package/dist/theme/components/Llms/LlmsContainer.js +9 -0
  96. package/dist/theme/components/Llms/LlmsCopyButton.css +57 -0
  97. package/dist/theme/components/Llms/LlmsCopyButton.d.ts +20 -0
  98. package/dist/theme/components/Llms/LlmsCopyButton.js +76 -0
  99. package/dist/theme/components/Llms/LlmsCopyButton.js.LICENSE.txt +5 -0
  100. package/dist/theme/components/Llms/LlmsViewOptions.css +93 -0
  101. package/dist/theme/components/Llms/LlmsViewOptions.d.ts +34 -0
  102. package/dist/theme/components/Llms/LlmsViewOptions.js +162 -0
  103. package/dist/theme/components/Llms/LlmsViewOptions.js.LICENSE.txt +5 -0
  104. package/dist/theme/components/Llms/index.css +32 -0
  105. package/dist/theme/components/Llms/index.d.ts +4 -0
  106. package/dist/theme/components/Llms/index.js +5 -0
  107. package/dist/theme/components/Llms/useMdUrl.d.ts +6 -0
  108. package/dist/theme/components/Llms/useMdUrl.js +15 -0
  109. package/dist/theme/components/Nav/index.css +1 -0
  110. package/dist/theme/components/Nav/index.js +1 -2
  111. package/dist/theme/components/{Nav/NavTitle.d.ts → NavTitle/index.d.ts} +1 -1
  112. package/dist/theme/components/{Nav/NavTitle.js → NavTitle/index.js} +11 -6
  113. package/dist/theme/components/Overview/index.js +1 -1
  114. package/dist/theme/components/OverviewGroup/index.d.ts +1 -1
  115. package/dist/theme/components/PageTabs/index.css +1 -1
  116. package/dist/theme/components/SvgWrapper/index.d.ts +9 -3
  117. package/dist/theme/components/SvgWrapper/index.js +22 -5
  118. package/dist/theme/components/Tabs/index.css +4 -4
  119. package/dist/theme/hooks/useDynamicToc.d.ts +2 -0
  120. package/dist/theme/hooks/useDynamicToc.js +3 -1
  121. package/dist/theme/icons.d.ts +2 -2
  122. package/dist/theme/icons.js +5 -5
  123. package/dist/theme/index.d.ts +2 -0
  124. package/dist/theme/index.js +3 -1
  125. package/dist/theme/layout/Layout/index.js +1 -1
  126. package/dist/theme/logic/useScrollAfterNav.js +1 -0
  127. package/package.json +15 -16
  128. package/dist/8813.4b28f4bb.js +0 -1
  129. package/dist/cli/config/index.d.ts +0 -2
  130. package/dist/theme/assets/right.js +0 -14
  131. package/dist/theme/assets/translator.js +0 -14
  132. /package/dist/{cli/config/index.js → config/defineConfig.js} +0 -0
  133. /package/dist/{cli/config → config}/loadConfigFile.d.ts +0 -0
  134. /package/dist/eject-theme/components/{Nav/NavTitle.scss → NavTitle/index.scss} +0 -0
  135. /package/dist/theme/components/{Nav/NavTitle.css → NavTitle/index.css} +0 -0
@@ -0,0 +1,209 @@
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, IconExternalLink, IconLink } from '@theme';
8
+ import type React from 'react';
9
+ import { useEffect, useMemo, useRef, useState } from 'react';
10
+ import { SvgWrapper } from '../SvgWrapper';
11
+ import './index.scss';
12
+ import './LlmsViewOptions.scss';
13
+ import { useMdUrl } from './useMdUrl';
14
+
15
+ type Option =
16
+ | {
17
+ title: string;
18
+ icon?: React.ReactNode;
19
+ onClick?: () => void;
20
+ }
21
+ | {
22
+ title: string;
23
+ href: string;
24
+ icon?: React.ReactNode;
25
+ }
26
+ | 'markdownLink'
27
+ | 'chatgpt'
28
+ | 'claude';
29
+
30
+ export interface LlmsViewOptionsProps
31
+ extends React.ButtonHTMLAttributes<HTMLButtonElement> {
32
+ /**
33
+ * Default options for the dropdown.
34
+ * @default ['markdownLink', 'chatgpt', 'claude']
35
+ * - 'chatgpt': Open in ChatGPT
36
+ * - 'claude': Open in Claude
37
+ */
38
+ options?: Option[];
39
+ /**
40
+ * Button text by language, used with `useLang`.
41
+ * @default en: 'Open', zh: '\u6253\u5f00'
42
+ */
43
+ textByLang?: Record<string, string>;
44
+ /**
45
+ * Button text.
46
+ * Priority is higher than textByLang
47
+ * @default ''
48
+ */
49
+ text?: string;
50
+ }
51
+
52
+ const DEFAULT_OPTIONS: Option[] = ['markdownLink', 'chatgpt', 'claude'];
53
+
54
+ export function LlmsViewOptions({
55
+ options: propsOptions,
56
+ }: LlmsViewOptionsProps) {
57
+ const { site } = useSite();
58
+ const llmsUI = site?.themeConfig?.llmsUI;
59
+ const options =
60
+ (typeof llmsUI === 'object' ? llmsUI?.viewOptions : propsOptions) ??
61
+ DEFAULT_OPTIONS;
62
+ const [isOpen, setIsOpen] = useState(false);
63
+ const dropdownRef = useRef<HTMLButtonElement>(null);
64
+
65
+ useEffect(() => {
66
+ const handleClickOutside = (event: MouseEvent) => {
67
+ if (
68
+ dropdownRef.current &&
69
+ event.target &&
70
+ !dropdownRef.current.contains(event.target as Node)
71
+ ) {
72
+ setIsOpen(false);
73
+ }
74
+ };
75
+
76
+ document.addEventListener('mousedown', handleClickOutside);
77
+ return () => {
78
+ document.removeEventListener('mousedown', handleClickOutside);
79
+ };
80
+ }, []);
81
+
82
+ const toggleDropdown = () => {
83
+ setIsOpen(!isOpen);
84
+ };
85
+
86
+ const { pathname } = useMdUrl();
87
+ const t = useI18n();
88
+
89
+ const items = useMemo(() => {
90
+ const fullMarkdownUrl =
91
+ typeof window !== 'undefined'
92
+ ? new URL(pathname, window.location.origin).toString()
93
+ : 'loading';
94
+ const q = `Read ${fullMarkdownUrl}, I want to ask questions about it.`;
95
+
96
+ return {
97
+ markdownLink: {
98
+ title: t('copyMarkdownLinkText'),
99
+ icon: <SvgWrapper icon={IconLink} />,
100
+ onClick: () => {
101
+ navigator.clipboard.writeText(fullMarkdownUrl);
102
+ },
103
+ },
104
+ chatgpt: {
105
+ title: t('openInText', { name: 'ChatGPT' }),
106
+ href: `https://chatgpt.com/?${new URLSearchParams({
107
+ hints: 'search',
108
+ q,
109
+ })}`,
110
+ icon: (
111
+ <svg
112
+ role="img"
113
+ viewBox="0 0 24 24"
114
+ fill="currentColor"
115
+ xmlns="http://www.w3.org/2000/svg"
116
+ >
117
+ <title>OpenAI</title>
118
+ <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" />
119
+ <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" />
120
+ </svg>
121
+ ),
122
+ },
123
+ claude: {
124
+ title: t('openInText', { name: 'Claude' }),
125
+ href: `https://claude.ai/new?${new URLSearchParams({
126
+ q,
127
+ })}`,
128
+ icon: (
129
+ <svg
130
+ fill="currentColor"
131
+ role="img"
132
+ viewBox="0 0 24 24"
133
+ xmlns="http://www.w3.org/2000/svg"
134
+ >
135
+ <title>Anthropic</title>
136
+ <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" />
137
+ </svg>
138
+ ),
139
+ },
140
+ };
141
+ }, [pathname, t]);
142
+
143
+ return (
144
+ <>
145
+ <button
146
+ ref={dropdownRef}
147
+ onClick={toggleDropdown}
148
+ className={`rp-llms-button rp-llms-view-options__trigger ${
149
+ isOpen ? 'rp-llms-view-options__trigger--active' : ''
150
+ }`}
151
+ >
152
+ <SvgWrapper
153
+ icon={IconDown}
154
+ className={`rp-llms-view-options__arrow ${isOpen ? 'rp-llms-view-options__arrow--rotated' : ''}`}
155
+ />
156
+ {isOpen && (
157
+ <div className="rp-llms-view-options__menu">
158
+ {options.map(item => {
159
+ let displayItem = item as {
160
+ title: string;
161
+ href?: string;
162
+ icon?: React.ReactNode;
163
+ onClick?: () => void;
164
+ };
165
+ if (item === 'markdownLink') {
166
+ displayItem = items.markdownLink;
167
+ } else if (item === 'chatgpt') {
168
+ displayItem = items.chatgpt;
169
+ } else if (item === 'claude') {
170
+ displayItem = items.claude;
171
+ }
172
+ if (displayItem.href) {
173
+ return (
174
+ <a
175
+ key={displayItem.title}
176
+ className="rp-llms-view-options__menu-item"
177
+ href={displayItem.href}
178
+ target="_blank"
179
+ rel="noopener noreferrer"
180
+ >
181
+ <span className="rp-llms-view-options__item-icon">
182
+ {displayItem.icon}
183
+ </span>
184
+ <span>{displayItem.title}</span>
185
+ <span className="rp-llms-view-options__external-icon">
186
+ <SvgWrapper icon={IconExternalLink} />
187
+ </span>
188
+ </a>
189
+ );
190
+ }
191
+ return (
192
+ <div
193
+ key={displayItem.title}
194
+ className="rp-llms-view-options__menu-item"
195
+ onClick={displayItem.onClick}
196
+ >
197
+ <span className="rp-llms-view-options__item-icon">
198
+ {displayItem.icon}
199
+ </span>
200
+ <span>{displayItem.title}</span>
201
+ </div>
202
+ );
203
+ })}
204
+ </div>
205
+ )}
206
+ </button>
207
+ </>
208
+ );
209
+ }
@@ -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>}
@@ -82,7 +82,9 @@ export function Overview(props: {
82
82
 
83
83
  // Added effect to focus search input on mount
84
84
  useEffect(() => {
85
- searchRef.current?.focus();
85
+ if (frontmatter.overview === true) {
86
+ searchRef.current?.focus();
87
+ }
86
88
  }, []);
87
89
 
88
90
  const subFilter = (link: string) =>
@@ -50,7 +50,7 @@ function OverviewGroupMarkdown({ group }: { group: Group }) {
50
50
  export interface GroupItem {
51
51
  text: string;
52
52
  link: string;
53
- headers?: Header[];
53
+ headers?: Omit<Header, 'charIndex'>[];
54
54
 
55
55
  // For customization
56
56
  items?: { text: string; link: string }[];
@@ -1,19 +1,53 @@
1
+ import { renderHtmlOrText } from '@theme';
2
+
3
+ /**
4
+ * Check if a string is a URL or file path
5
+ */
6
+ function isUrlOrPath(str: string): boolean {
7
+ return (
8
+ str.startsWith('/') ||
9
+ str.startsWith('./') ||
10
+ str.startsWith('../') ||
11
+ str.startsWith('http://') ||
12
+ str.startsWith('https://') ||
13
+ str.startsWith('data:')
14
+ );
15
+ }
16
+
17
+ type SvgWrapperProps = {
18
+ icon: string | React.FC<React.SVGProps<SVGSVGElement>>;
19
+ } & React.SVGProps<SVGSVGElement>;
20
+
1
21
  /**
2
22
  * A wrapper for custom SVG icon.
3
23
  * When the user uses a custom SVG, the imported icon can be a string or a React component.
24
+ * - React component: render directly
25
+ * - SVG string (starts with `<svg`): render with dangerouslySetInnerHTML
26
+ * - URL/path: render with `<img>`
27
+ * - Other strings (emoji/text/HTML): render with renderHtmlOrText
4
28
  * @internal
5
29
  */
6
- export function SvgWrapper({
7
- icon: Icon,
8
- ...rest
9
- }: {
10
- icon: string | React.FC<React.SVGProps<SVGSVGElement>>;
11
- } & React.SVGAttributes<SVGSVGElement | HTMLImageElement>) {
30
+ export function SvgWrapper({ icon: Icon, ...rest }: SvgWrapperProps) {
12
31
  if (!Icon) {
13
32
  return null;
14
33
  }
15
34
  if (typeof Icon === 'string') {
16
- return <img src={Icon} alt="" {...rest} />;
35
+ const { className } = rest;
36
+ // SVG inline string
37
+ if (Icon.trim().startsWith('<svg')) {
38
+ return (
39
+ <span
40
+ className={className}
41
+ dangerouslySetInnerHTML={{ __html: Icon }}
42
+ />
43
+ );
44
+ }
45
+ // URL or file path
46
+ if (isUrlOrPath(Icon)) {
47
+ return <img className={className} src={Icon} alt="" />;
48
+ }
49
+ // Fallback: emoji/text/HTML
50
+ return <span className={className} {...renderHtmlOrText(Icon)} />;
17
51
  }
18
52
 
19
53
  return <Icon {...rest} />;
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 "./9446.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 "../../9446.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.e8bfcd99.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.e8bfcd99.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 "../9446.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: {
@@ -189,6 +190,13 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
189
190
  }
190
191
  },
191
192
  tools: {
193
+ swc: {
194
+ jsc: {
195
+ transform: {
196
+ verbatimModuleSyntax: false
197
+ }
198
+ }
199
+ },
192
200
  bundlerChain (chain, { CHAIN_ID, environment }) {
193
201
  const isSsg = 'node' === environment.name;
194
202
  const isSsgMd = 'node_md' === environment.name;
@@ -291,6 +299,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
291
299
  output: {
292
300
  emitAssets: false,
293
301
  target: 'node',
302
+ module: false,
294
303
  minify: false
295
304
  }
296
305
  }
@@ -330,6 +339,7 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
330
339
  output: {
331
340
  emitAssets: false,
332
341
  target: 'node',
342
+ module: false,
333
343
  minify: false
334
344
  }
335
345
  }
@@ -1,4 +1,4 @@
1
- import { execa } from "../../0~7675.4468968d.js";
1
+ import { execa } from "../../0~7675.efbf8813.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 '';