@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,162 @@
1
+ /*! For license information please see LlmsViewOptions.js.LICENSE.txt */
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { useI18n, useSite } from "@rspress/core/runtime";
4
+ import { IconDown, IconExternalLink, IconLink } from "@theme";
5
+ import { useEffect, useMemo, useRef, useState } from "react";
6
+ import { SvgWrapper } from "../SvgWrapper/index.js";
7
+ import "./index.css";
8
+ import "./LlmsViewOptions.css";
9
+ import { useMdUrl } from "./useMdUrl.js";
10
+ /**
11
+ * Inspired from fumadocs docsite
12
+ * @from https://github.com/fuma-nama/fumadocs/blob/5723bbe58ef805a5421a780abf235a10b251be2f/apps/docs/app/docs/%5B...slug%5D/page.client.tsx#L11
13
+ * @license MIT
14
+ */ const DEFAULT_OPTIONS = [
15
+ 'markdownLink',
16
+ 'chatgpt',
17
+ 'claude'
18
+ ];
19
+ function LlmsViewOptions({ options: propsOptions }) {
20
+ const { site } = useSite();
21
+ const llmsUI = site?.themeConfig?.llmsUI;
22
+ const options = ('object' == typeof llmsUI ? llmsUI?.viewOptions : propsOptions) ?? DEFAULT_OPTIONS;
23
+ const [isOpen, setIsOpen] = useState(false);
24
+ const dropdownRef = useRef(null);
25
+ useEffect(()=>{
26
+ const handleClickOutside = (event)=>{
27
+ if (dropdownRef.current && event.target && !dropdownRef.current.contains(event.target)) setIsOpen(false);
28
+ };
29
+ document.addEventListener('mousedown', handleClickOutside);
30
+ return ()=>{
31
+ document.removeEventListener('mousedown', handleClickOutside);
32
+ };
33
+ }, []);
34
+ const toggleDropdown = ()=>{
35
+ setIsOpen(!isOpen);
36
+ };
37
+ const { pathname } = useMdUrl();
38
+ const t = useI18n();
39
+ const items = useMemo(()=>{
40
+ const fullMarkdownUrl = "u" > typeof window ? new URL(pathname, window.location.origin).toString() : 'loading';
41
+ const q = `Read ${fullMarkdownUrl}, I want to ask questions about it.`;
42
+ return {
43
+ markdownLink: {
44
+ title: t('copyMarkdownLinkText'),
45
+ icon: /*#__PURE__*/ jsx(SvgWrapper, {
46
+ icon: IconLink
47
+ }),
48
+ onClick: ()=>{
49
+ navigator.clipboard.writeText(fullMarkdownUrl);
50
+ }
51
+ },
52
+ chatgpt: {
53
+ title: t('openInText', {
54
+ name: 'ChatGPT'
55
+ }),
56
+ href: `https://chatgpt.com/?${new URLSearchParams({
57
+ hints: 'search',
58
+ q
59
+ })}`,
60
+ icon: /*#__PURE__*/ jsxs("svg", {
61
+ role: "img",
62
+ viewBox: "0 0 24 24",
63
+ fill: "currentColor",
64
+ xmlns: "http://www.w3.org/2000/svg",
65
+ children: [
66
+ /*#__PURE__*/ jsx("title", {
67
+ children: "OpenAI"
68
+ }),
69
+ /*#__PURE__*/ jsx("path", {
70
+ 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"
71
+ }),
72
+ /*#__PURE__*/ jsx("path", {
73
+ 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"
74
+ })
75
+ ]
76
+ })
77
+ },
78
+ claude: {
79
+ title: t('openInText', {
80
+ name: 'Claude'
81
+ }),
82
+ href: `https://claude.ai/new?${new URLSearchParams({
83
+ q
84
+ })}`,
85
+ icon: /*#__PURE__*/ jsxs("svg", {
86
+ fill: "currentColor",
87
+ role: "img",
88
+ viewBox: "0 0 24 24",
89
+ xmlns: "http://www.w3.org/2000/svg",
90
+ children: [
91
+ /*#__PURE__*/ jsx("title", {
92
+ children: "Anthropic"
93
+ }),
94
+ /*#__PURE__*/ jsx("path", {
95
+ 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"
96
+ })
97
+ ]
98
+ })
99
+ }
100
+ };
101
+ }, [
102
+ pathname,
103
+ t
104
+ ]);
105
+ return /*#__PURE__*/ jsx(Fragment, {
106
+ children: /*#__PURE__*/ jsxs("button", {
107
+ ref: dropdownRef,
108
+ onClick: toggleDropdown,
109
+ className: `rp-llms-button rp-llms-view-options__trigger ${isOpen ? 'rp-llms-view-options__trigger--active' : ''}`,
110
+ children: [
111
+ /*#__PURE__*/ jsx(SvgWrapper, {
112
+ icon: IconDown,
113
+ className: `rp-llms-view-options__arrow ${isOpen ? 'rp-llms-view-options__arrow--rotated' : ''}`
114
+ }),
115
+ isOpen && /*#__PURE__*/ jsx("div", {
116
+ className: "rp-llms-view-options__menu",
117
+ children: options.map((item)=>{
118
+ let displayItem = item;
119
+ if ('markdownLink' === item) displayItem = items.markdownLink;
120
+ else if ('chatgpt' === item) displayItem = items.chatgpt;
121
+ else if ('claude' === item) displayItem = items.claude;
122
+ if (displayItem.href) return /*#__PURE__*/ jsxs("a", {
123
+ className: "rp-llms-view-options__menu-item",
124
+ href: displayItem.href,
125
+ target: "_blank",
126
+ rel: "noopener noreferrer",
127
+ children: [
128
+ /*#__PURE__*/ jsx("span", {
129
+ className: "rp-llms-view-options__item-icon",
130
+ children: displayItem.icon
131
+ }),
132
+ /*#__PURE__*/ jsx("span", {
133
+ children: displayItem.title
134
+ }),
135
+ /*#__PURE__*/ jsx("span", {
136
+ className: "rp-llms-view-options__external-icon",
137
+ children: /*#__PURE__*/ jsx(SvgWrapper, {
138
+ icon: IconExternalLink
139
+ })
140
+ })
141
+ ]
142
+ }, displayItem.title);
143
+ return /*#__PURE__*/ jsxs("div", {
144
+ className: "rp-llms-view-options__menu-item",
145
+ onClick: displayItem.onClick,
146
+ children: [
147
+ /*#__PURE__*/ jsx("span", {
148
+ className: "rp-llms-view-options__item-icon",
149
+ children: displayItem.icon
150
+ }),
151
+ /*#__PURE__*/ jsx("span", {
152
+ children: displayItem.title
153
+ })
154
+ ]
155
+ }, displayItem.title);
156
+ })
157
+ })
158
+ ]
159
+ })
160
+ });
161
+ }
162
+ export { LlmsViewOptions };
@@ -0,0 +1,5 @@
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
+ */
@@ -0,0 +1,32 @@
1
+ .rp-llms-button {
2
+ border: 1px solid var(--rp-c-divider-light);
3
+ background: var(--rp-c-bg);
4
+ height: 36px;
5
+ color: var(--rp-c-text-2);
6
+ user-select: none;
7
+ white-space: nowrap;
8
+ cursor: pointer;
9
+ border-radius: 8px;
10
+ justify-content: center;
11
+ align-items: center;
12
+ gap: 6px;
13
+ padding: 0 12px;
14
+ font-size: 14px;
15
+ font-weight: 500;
16
+ line-height: normal;
17
+ transition: background .2s, border-color .2s, color .2s, box-shadow .2s, transform .1s, opacity .2s;
18
+ display: inline-flex;
19
+ }
20
+
21
+ .rp-llms-button:hover {
22
+ background: var(--rp-c-bg-soft);
23
+ border-color: var(--rp-c-divider);
24
+ color: var(--rp-c-text-1);
25
+ box-shadow: 0 2px 6px #0000000a;
26
+ }
27
+
28
+ .rp-llms-button:active {
29
+ background: var(--rp-c-bg-soft);
30
+ box-shadow: none;
31
+ }
32
+
@@ -0,0 +1,4 @@
1
+ export { LlmsContainer, type LlmsContainerProps } from './LlmsContainer.js';
2
+ export { LlmsCopyButton, type LlmsCopyButtonProps } from './LlmsCopyButton.js';
3
+ export { LlmsViewOptions, type LlmsViewOptionsProps } from './LlmsViewOptions.js';
4
+ export { useMdUrl } from './useMdUrl.js';
@@ -0,0 +1,5 @@
1
+ import { LlmsContainer } from "./LlmsContainer.js";
2
+ import { LlmsCopyButton } from "./LlmsCopyButton.js";
3
+ import { LlmsViewOptions } from "./LlmsViewOptions.js";
4
+ import { useMdUrl } from "./useMdUrl.js";
5
+ export { LlmsContainer, LlmsCopyButton, LlmsViewOptions, useMdUrl };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @private
3
+ */
4
+ export declare function useMdUrl(): {
5
+ pathname: string;
6
+ };
@@ -0,0 +1,15 @@
1
+ import { routePathToMdPath, usePageData } from "@rspress/core/runtime";
2
+ import { useMemo } from "react";
3
+ function useMdUrl() {
4
+ const { page } = usePageData();
5
+ const mdPath = useMemo(()=>{
6
+ const pathname = routePathToMdPath(page.routePath);
7
+ return {
8
+ pathname
9
+ };
10
+ }, [
11
+ page.routePath
12
+ ]);
13
+ return mdPath;
14
+ }
15
+ export { useMdUrl };
@@ -11,6 +11,7 @@
11
11
  justify-content: space-between;
12
12
  align-items: center;
13
13
  width: 100%;
14
+ transition: background-color .2s ease-in-out, border-bottom .2s ease-in-out;
14
15
  display: flex;
15
16
  position: sticky;
16
17
  left: 0;
@@ -1,9 +1,8 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useNav } from "@rspress/core/runtime";
3
- import { NavHamburger, Search, SocialLinks, SwitchAppearance } from "@theme";
3
+ import { NavHamburger, NavTitle, Search, SocialLinks, SwitchAppearance } from "@theme";
4
4
  import "./index.css";
5
5
  import { NavLangs, NavMenu, NavMenuDivider, NavVersions } from "./NavMenu.js";
6
- import { NavTitle } from "./NavTitle.js";
7
6
  function Nav(props) {
8
7
  const { beforeNavTitle, afterNavTitle, beforeNavMenu, afterNavMenu, navTitle } = props;
9
8
  const navList = useNav();
@@ -1,2 +1,2 @@
1
- import './NavTitle.scss';
1
+ import './index.scss';
2
2
  export declare const NavTitle: () => import("react/jsx-runtime").JSX.Element;
@@ -1,13 +1,18 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- import { addLeadingSlash, normalizeImagePath, useLocaleSiteData, useSite } from "@rspress/core/runtime";
2
+ import { addLeadingSlash, addTrailingSlash, normalizeImagePath, useLang, useSite } from "@rspress/core/runtime";
3
3
  import { Link } from "@theme";
4
4
  import { useMemo } from "react";
5
- import "./NavTitle.css";
5
+ import "./index.css";
6
6
  const NavTitle = ()=>{
7
7
  const { site } = useSite();
8
- const localeData = useLocaleSiteData();
9
- const { logo: rawLogo, logoText } = site;
10
- const title = (localeData.title ?? site.title) || 'Home';
8
+ const lang = useLang();
9
+ const themeConfig = site?.themeConfig ?? {};
10
+ const defaultLang = site.lang ?? '';
11
+ const locales = themeConfig?.locales;
12
+ const localeInfo = locales?.find((locale)=>locale.lang === lang);
13
+ const title = (localeInfo?.title ?? site.title) || 'Home';
14
+ const langRoutePrefix = lang === defaultLang ? '/' : addTrailingSlash(lang);
15
+ const { logo: rawLogo, logoText, logoHref } = site;
11
16
  const logo = useMemo(()=>{
12
17
  if (!rawLogo) return null;
13
18
  if ('string' == typeof rawLogo) return /*#__PURE__*/ jsx("img", {
@@ -38,7 +43,7 @@ const NavTitle = ()=>{
38
43
  return /*#__PURE__*/ jsx("div", {
39
44
  className: "rp-nav__title",
40
45
  children: /*#__PURE__*/ jsxs(Link, {
41
- href: addLeadingSlash(localeData.langRoutePrefix ?? '/'),
46
+ href: logoHref || addLeadingSlash(langRoutePrefix),
42
47
  className: "rp-nav__title__link",
43
48
  children: [
44
49
  logo && /*#__PURE__*/ jsx("div", {
@@ -36,7 +36,7 @@ function Overview(props) {
36
36
  const [query, setQuery] = useState('');
37
37
  const searchRef = useRef(null);
38
38
  useEffect(()=>{
39
- searchRef.current?.focus();
39
+ if (true === frontmatter.overview) searchRef.current?.focus();
40
40
  }, []);
41
41
  const subFilter = (link)=>link.startsWith(routePath.replace(/overview$/, '')) && !isEqualPath(link, routePath);
42
42
  const getChildLink = (traverseItem)=>{
@@ -3,7 +3,7 @@ import type { Header } from '@rspress/core';
3
3
  export interface GroupItem {
4
4
  text: string;
5
5
  link: string;
6
- headers?: Header[];
6
+ headers?: Omit<Header, 'charIndex'>[];
7
7
  items?: {
8
8
  text: string;
9
9
  link: string;
@@ -27,7 +27,7 @@ body[data-page-tabs-active-index="0"] .rp-page-tabs__label__item[data-index="0"]
27
27
  font-weight: 700;
28
28
  }
29
29
 
30
- .rp-page-tabs__content__item, .rp-page-tabs__content__item h2:first-of-type:before {
30
+ .rp-page-tabs__content__item h2:first-of-type:before, .rp-page-tabs__content__item {
31
31
  display: none;
32
32
  }
33
33
 
@@ -1,8 +1,14 @@
1
+ type SvgWrapperProps = {
2
+ icon: string | React.FC<React.SVGProps<SVGSVGElement>>;
3
+ } & React.SVGProps<SVGSVGElement>;
1
4
  /**
2
5
  * A wrapper for custom SVG icon.
3
6
  * When the user uses a custom SVG, the imported icon can be a string or a React component.
7
+ * - React component: render directly
8
+ * - SVG string (starts with `<svg`): render with dangerouslySetInnerHTML
9
+ * - URL/path: render with `<img>`
10
+ * - Other strings (emoji/text/HTML): render with renderHtmlOrText
4
11
  * @internal
5
12
  */
6
- export declare function SvgWrapper({ icon: Icon, ...rest }: {
7
- icon: string | React.FC<React.SVGProps<SVGSVGElement>>;
8
- } & React.SVGAttributes<SVGSVGElement | HTMLImageElement>): import("react/jsx-runtime").JSX.Element | null;
13
+ export declare function SvgWrapper({ icon: Icon, ...rest }: SvgWrapperProps): import("react/jsx-runtime").JSX.Element | null;
14
+ export {};
@@ -1,11 +1,28 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
+ import { renderHtmlOrText } from "@theme";
3
+ function isUrlOrPath(str) {
4
+ return str.startsWith('/') || str.startsWith('./') || str.startsWith('../') || str.startsWith('http://') || str.startsWith('https://') || str.startsWith('data:');
5
+ }
2
6
  function SvgWrapper({ icon: Icon, ...rest }) {
3
7
  if (!Icon) return null;
4
- if ('string' == typeof Icon) return /*#__PURE__*/ jsx("img", {
5
- src: Icon,
6
- alt: "",
7
- ...rest
8
- });
8
+ if ('string' == typeof Icon) {
9
+ const { className } = rest;
10
+ if (Icon.trim().startsWith('<svg')) return /*#__PURE__*/ jsx("span", {
11
+ className: className,
12
+ dangerouslySetInnerHTML: {
13
+ __html: Icon
14
+ }
15
+ });
16
+ if (isUrlOrPath(Icon)) return /*#__PURE__*/ jsx("img", {
17
+ className: className,
18
+ src: Icon,
19
+ alt: ""
20
+ });
21
+ return /*#__PURE__*/ jsx("span", {
22
+ className: className,
23
+ ...renderHtmlOrText(Icon)
24
+ });
25
+ }
9
26
  return /*#__PURE__*/ jsx(Icon, {
10
27
  ...rest
11
28
  });
@@ -25,15 +25,15 @@
25
25
  display: flex;
26
26
  }
27
27
 
28
+ .rp-tabs__label--no-scrollbar::-webkit-scrollbar {
29
+ display: none;
30
+ }
31
+
28
32
  .rp-tabs__label--no-scrollbar {
29
33
  -ms-overflow-style: none;
30
34
  scrollbar-width: none;
31
35
  }
32
36
 
33
- .rp-tabs__label--no-scrollbar::-webkit-scrollbar {
34
- display: none;
35
- }
36
-
37
37
  .rp-tabs__label__item {
38
38
  word-break: keep-all;
39
39
  color: var(--rp-c-text-2);
@@ -1,5 +1,7 @@
1
1
  import type { Header } from '@rspress/core';
2
2
  /**
3
+ * 1. in first render, use the toc generated by remark plugin
4
+ * 2. after mounted, use the dynamically collected toc on the page
3
5
  * @internal
4
6
  */
5
7
  export declare const useDynamicToc: () => Header[];
@@ -1,3 +1,4 @@
1
+ import { usePage } from "@rspress/core/runtime";
1
2
  import { useCallback, useEffect, useState } from "react";
2
3
  import { processTitleElement } from "./processTitleElement.js";
3
4
  const updateFns = {};
@@ -38,8 +39,9 @@ function isElementVisible(element) {
38
39
  return true;
39
40
  }
40
41
  const useDynamicToc = ()=>{
42
+ const { page: { toc = [] } } = usePage();
41
43
  useSubScribe();
42
- return headers.current;
44
+ return headers.current.length > 0 ? headers.current : toc;
43
45
  };
44
46
  function updateHeaders(target) {
45
47
  const collectedHeaders = [];
@@ -15,13 +15,13 @@ export declare const IconJump: Icon;
15
15
  export declare const IconLoading: Icon;
16
16
  export declare const IconMenu: Icon;
17
17
  export declare const IconMoon: Icon;
18
- export declare const IconRight: Icon;
19
18
  export declare const IconSearch: Icon;
20
19
  export declare const IconSmallMenu: Icon;
21
20
  export declare const IconSuccess: Icon;
22
21
  export declare const IconSun: Icon;
23
22
  export declare const IconTitle: Icon;
24
- export declare const IconTranslator: Icon;
25
23
  export declare const IconWrap: Icon;
26
24
  export declare const IconWrapped: Icon;
25
+ export declare const IconExternalLink: Icon;
26
+ export declare const IconLink: Icon;
27
27
  export {};
@@ -6,21 +6,21 @@ import deprecated from "./assets/deprecated.js";
6
6
  import down from "./assets/down.js";
7
7
  import empty from "./assets/empty.js";
8
8
  import experimental from "./assets/experimental.js";
9
+ import external_link from "./assets/external-link.js";
9
10
  import file from "./assets/file.js";
10
11
  import github from "./assets/github.js";
11
12
  import gitlab from "./assets/gitlab.js";
12
13
  import header from "./assets/header.js";
13
14
  import jump from "./assets/jump.js";
15
+ import assets_link from "./assets/link.js";
14
16
  import loading from "./assets/loading.js";
15
17
  import menu from "./assets/menu.js";
16
18
  import moon from "./assets/moon.js";
17
- import right from "./assets/right.js";
18
19
  import search from "./assets/search.js";
19
20
  import small_menu from "./assets/small-menu.js";
20
21
  import success from "./assets/success.js";
21
22
  import sun from "./assets/sun.js";
22
23
  import title from "./assets/title.js";
23
- import translator from "./assets/translator.js";
24
24
  import wrap from "./assets/wrap.js";
25
25
  import wrapped from "./assets/wrapped.js";
26
26
  const IconDeprecated = deprecated;
@@ -39,13 +39,13 @@ const IconJump = jump;
39
39
  const IconLoading = loading;
40
40
  const IconMenu = menu;
41
41
  const IconMoon = moon;
42
- const IconRight = right;
43
42
  const IconSearch = search;
44
43
  const IconSmallMenu = small_menu;
45
44
  const IconSuccess = success;
46
45
  const IconSun = sun;
47
46
  const IconTitle = title;
48
- const IconTranslator = translator;
49
47
  const IconWrap = wrap;
50
48
  const IconWrapped = wrapped;
51
- export { IconArrowDown, IconArrowRight, IconClose, IconCopy, IconDeprecated, IconDown, IconEmpty, IconExperimental, IconFile, IconGithub, IconGitlab, IconHeader, IconJump, IconLoading, IconMenu, IconMoon, IconRight, IconSearch, IconSmallMenu, IconSuccess, IconSun, IconTitle, IconTranslator, IconWrap, IconWrapped };
49
+ const IconExternalLink = external_link;
50
+ const IconLink = assets_link;
51
+ export { IconArrowDown, IconArrowRight, IconClose, IconCopy, IconDeprecated, IconDown, IconEmpty, IconExperimental, IconExternalLink, IconFile, IconGithub, IconGitlab, IconHeader, IconJump, IconLink, IconLoading, IconMenu, IconMoon, IconSearch, IconSmallMenu, IconSuccess, IconSun, IconTitle, IconWrap, IconWrapped };
@@ -21,8 +21,10 @@ export { useHoverGroup } from './components/HoverGroup/useHoverGroup.js';
21
21
  export { LastUpdated } from './components/LastUpdated/index.js';
22
22
  export { Link, type LinkProps } from './components/Link/index.js';
23
23
  export { useLinkNavigate } from './components/Link/useLinkNavigate.js';
24
+ export { LlmsContainer, type LlmsContainerProps, LlmsCopyButton, type LlmsCopyButtonProps, LlmsViewOptions, type LlmsViewOptionsProps, useMdUrl, } from './components/Llms/index.js';
24
25
  export { Nav, type NavProps } from './components/Nav/index.js';
25
26
  export { NavHamburger } from './components/NavHamburger/index.js';
27
+ export { NavTitle } from './components/NavTitle/index.js';
26
28
  export { Outline } from './components/Outline/index.js';
27
29
  export { Overview } from './components/Overview/index.js';
28
30
  export { type Group, type GroupItem, OverviewGroup, } from './components/OverviewGroup/index.js';
@@ -20,8 +20,10 @@ import { useHoverGroup } from "./components/HoverGroup/useHoverGroup.js";
20
20
  import { LastUpdated } from "./components/LastUpdated/index.js";
21
21
  import { Link } from "./components/Link/index.js";
22
22
  import { useLinkNavigate } from "./components/Link/useLinkNavigate.js";
23
+ import { LlmsContainer, LlmsCopyButton, LlmsViewOptions, useMdUrl } from "./components/Llms/index.js";
23
24
  import { Nav } from "./components/Nav/index.js";
24
25
  import { NavHamburger } from "./components/NavHamburger/index.js";
26
+ import { NavTitle } from "./components/NavTitle/index.js";
25
27
  import { Outline } from "./components/Outline/index.js";
26
28
  import { Overview } from "./components/Overview/index.js";
27
29
  import { OverviewGroup } from "./components/OverviewGroup/index.js";
@@ -60,4 +62,4 @@ import { useStorageValue } from "./logic/useStorageValue.js";
60
62
  import { useThemeState } from "./logic/useThemeState.js";
61
63
  import { parseInlineMarkdownText, renderHtmlOrText, renderInlineMarkdown } from "./logic/utils.js";
62
64
  export * from "./icons.js";
63
- export { Badge, Banner, Button, Callout, CodeBlock, CodeBlockRuntime, CodeButtonGroup, DocContent, DocFooter, DocLayout, EditLink, FallbackHeading, HomeBackground, HomeFeature, HomeFooter, HomeHero, HomeLayout, HoverGroup, LastUpdated, Layout, Link, Nav, NavHamburger, NotFoundLayout, Outline, Overview, OverviewGroup, PackageManagerTabs, PageTab, PageTabs, PrevNextPage, ReadPercent, RenderType, Root, Search, SearchButton, SearchPanel, Sidebar, SidebarList, SocialLinks, SourceCode, Steps, SvgWrapper, SwitchAppearance, Tab, Tabs, Tag, Toc, getCustomMDXComponent, mergeRefs, parseInlineMarkdownText, renderHtmlOrText, renderInlineMarkdown, useActiveAnchor, useCodeButtonGroup, useDynamicToc, useEditLink, useFullTextSearch, useHoverGroup, useLinkNavigate, usePrevNextPage, useRedirect4FirstVisit, useScrollAfterNav, useScrollReset, useSetup, useStorageValue, useThemeState, useWatchToc };
65
+ export { Badge, Banner, Button, Callout, CodeBlock, CodeBlockRuntime, CodeButtonGroup, DocContent, DocFooter, DocLayout, EditLink, FallbackHeading, HomeBackground, HomeFeature, HomeFooter, HomeHero, HomeLayout, HoverGroup, LastUpdated, Layout, Link, LlmsContainer, LlmsCopyButton, LlmsViewOptions, Nav, NavHamburger, NavTitle, NotFoundLayout, Outline, Overview, OverviewGroup, PackageManagerTabs, PageTab, PageTabs, PrevNextPage, ReadPercent, RenderType, Root, Search, SearchButton, SearchPanel, Sidebar, SidebarList, SocialLinks, SourceCode, Steps, SvgWrapper, SwitchAppearance, Tab, Tabs, Tag, Toc, getCustomMDXComponent, mergeRefs, parseInlineMarkdownText, renderHtmlOrText, renderInlineMarkdown, useActiveAnchor, useCodeButtonGroup, useDynamicToc, useEditLink, useFullTextSearch, useHoverGroup, useLinkNavigate, useMdUrl, usePrevNextPage, useRedirect4FirstVisit, useScrollAfterNav, useScrollReset, useSetup, useStorageValue, useThemeState, useWatchToc };
@@ -71,7 +71,7 @@ function Layout(props) {
71
71
  let title = frontmatter.title ?? articleTitle;
72
72
  const mainTitle = site.title || localesData.title || '';
73
73
  title = title && ('doc' === pageType || 'doc-wide' === pageType) ? concatTitle(title, frontmatter.titleSuffix || mainTitle) : 'home' === pageType ? concatTitle(mainTitle, frontmatter.titleSuffix) : '404' === pageType ? concatTitle('404', mainTitle) : mainTitle;
74
- const description = frontmatter?.description || site.description || localesData.description;
74
+ const description = page.description || site.description || localesData.description;
75
75
  const getContentLayout = ()=>{
76
76
  switch(pageType){
77
77
  case 'home':
@@ -21,6 +21,7 @@ function scrollToTarget(target) {
21
21
  function useScrollAfterNav() {
22
22
  const location = useLocation();
23
23
  useLayoutEffect(()=>{
24
+ if ("u" < typeof window) return;
24
25
  const decodedHash = decodeURIComponent(window.location.hash);
25
26
  if (decodedHash.length > 0) {
26
27
  const target = document.getElementById(decodedHash.slice(1));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress/core",
3
- "version": "2.0.0-rc.5",
3
+ "version": "2.0.0-rc.7",
4
4
  "description": "The Rspress Documentation Framework",
5
5
  "bugs": "https://github.com/web-infra-dev/rspress/issues",
6
6
  "repository": {
@@ -63,12 +63,11 @@
63
63
  "dependencies": {
64
64
  "@mdx-js/mdx": "^3.1.1",
65
65
  "@mdx-js/react": "^3.1.1",
66
- "@rsbuild/core": "~1.7.1",
67
- "@rsbuild/plugin-react": "~1.4.2",
68
- "@rspress/mdx-rs": "0.6.6",
69
- "@shikijs/rehype": "^3.20.0",
66
+ "@rsbuild/core": "2.0.0-alpha.2",
67
+ "@rsbuild/plugin-react": "~1.4.3",
68
+ "@shikijs/rehype": "^3.21.0",
70
69
  "@types/unist": "^3.0.3",
71
- "@unhead/react": "^2.1.1",
70
+ "@unhead/react": "^2.1.2",
72
71
  "body-scroll-lock": "4.0.0-beta.0",
73
72
  "cac": "^6.7.14",
74
73
  "chokidar": "^3.6.0",
@@ -78,7 +77,6 @@
78
77
  "github-slugger": "^2.0.0",
79
78
  "hast-util-heading-rank": "^3.0.0",
80
79
  "hast-util-to-jsx-runtime": "^2.3.6",
81
- "html-to-text": "^9.0.5",
82
80
  "lodash-es": "^4.17.22",
83
81
  "mdast-util-mdx": "^3.0.0",
84
82
  "mdast-util-mdxjs-esm": "^2.0.1",
@@ -89,37 +87,38 @@
89
87
  "react-dom": "^19.2.3",
90
88
  "react-lazy-with-preload": "^2.2.1",
91
89
  "react-reconciler": "0.33.0",
92
- "react-router-dom": "^7.11.0",
90
+ "react-router-dom": "^7.12.0",
93
91
  "rehype-external-links": "^3.0.0",
94
92
  "rehype-raw": "^7.0.0",
95
93
  "remark-gfm": "^4.0.1",
96
94
  "remark-mdx": "^3.1.1",
95
+ "remark-parse": "^11.0.0",
97
96
  "remark-stringify": "^11.0.0",
98
97
  "scroll-into-view-if-needed": "^3.1.0",
99
- "shiki": "^3.20.0",
98
+ "shiki": "^3.21.0",
100
99
  "tinyglobby": "^0.2.15",
101
100
  "tinypool": "^1.1.1",
102
101
  "unified": "^11.0.5",
102
+ "unist-util-remove": "^4.0.0",
103
103
  "unist-util-visit": "^5.0.0",
104
104
  "unist-util-visit-children": "^3.0.0",
105
- "@rspress/shared": "2.0.0-rc.5"
105
+ "@rspress/shared": "2.0.0-rc.7"
106
106
  },
107
107
  "devDependencies": {
108
108
  "@microsoft/api-extractor": "^7.55.2",
109
- "@rsbuild/plugin-sass": "~1.4.0",
110
- "@rsbuild/plugin-svgr": "^1.2.3",
111
- "@rslib/core": "0.19.1",
109
+ "@rsbuild/plugin-sass": "~1.4.1",
110
+ "@rsbuild/plugin-svgr": "^1.2.4",
111
+ "@rslib/core": "0.19.2",
112
112
  "@types/body-scroll-lock": "^3.1.2",
113
113
  "@types/hast": "^3.0.4",
114
- "@types/html-to-text": "^9.0.4",
115
114
  "@types/lodash-es": "^4.17.12",
116
115
  "@types/mdast": "^4.0.4",
117
116
  "@types/node": "^22.8.1",
118
117
  "@types/nprogress": "^0.2.3",
119
- "@types/react": "^19.2.7",
118
+ "@types/react": "^19.2.8",
120
119
  "@types/react-dom": "^19.2.3",
121
120
  "@types/react-reconciler": "^0.32.3",
122
- "@types/web": "^0.0.312",
121
+ "@types/web": "^0.0.318",
123
122
  "execa": "8.0.1",
124
123
  "mdast-util-directive": "^3.1.0",
125
124
  "mdast-util-mdx-expression": "^2.0.1",
@@ -1 +0,0 @@
1
- export { visit } from "unist-util-visit";
@@ -1,2 +0,0 @@
1
- import type { UserConfig } from '@rspress/shared';
2
- export declare function defineConfig(config: UserConfig): UserConfig;