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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/dist/{0~7675.723d12b2.js → 0~7675.d236b058.js} +3 -3
  2. package/dist/{5485.9fc7f63d.js → 5485.7586c86a.js} +1 -1
  3. package/dist/{3521.9eb6b114.js → 7786.421b464f.js} +2 -2
  4. package/dist/9348.1beb3e25.js +11 -0
  5. package/dist/_private/react/render.js +1 -1
  6. package/dist/cli/index.js +2 -2
  7. package/dist/config/defineConfig.d.ts +40 -0
  8. package/dist/{cli/config → config}/loadConfigFile.js +2 -2
  9. package/dist/eject-theme/components/Callout/index.scss +6 -6
  10. package/dist/eject-theme/components/CodeBlock/index.tsx +1 -1
  11. package/dist/eject-theme/components/DocContent/docComponents/title.tsx +21 -2
  12. package/dist/eject-theme/components/FallbackHeading/index.tsx +4 -0
  13. package/dist/eject-theme/components/HomeBackground/useNavTransparent.tsx +2 -1
  14. package/dist/eject-theme/components/HomeHero/index.scss +8 -0
  15. package/dist/eject-theme/components/HomeHero/index.tsx +11 -2
  16. package/dist/eject-theme/components/Llms/LlmsContainer.scss +6 -0
  17. package/dist/eject-theme/components/Llms/LlmsContainer.tsx +9 -0
  18. package/dist/eject-theme/components/Llms/LlmsCopyButton.scss +57 -0
  19. package/dist/eject-theme/components/Llms/LlmsCopyButton.tsx +94 -0
  20. package/dist/eject-theme/components/Llms/LlmsViewOptions.scss +98 -0
  21. package/dist/eject-theme/components/Llms/LlmsViewOptions.tsx +259 -0
  22. package/dist/eject-theme/components/Llms/index.scss +42 -0
  23. package/dist/eject-theme/components/Llms/index.tsx +4 -0
  24. package/dist/eject-theme/components/Llms/useMdUrl.ts +14 -0
  25. package/dist/eject-theme/components/Nav/index.scss +3 -0
  26. package/dist/eject-theme/components/Nav/index.tsx +7 -2
  27. package/dist/eject-theme/components/{Nav/NavTitle.tsx → NavTitle/index.tsx} +15 -6
  28. package/dist/eject-theme/components/Overview/index.tsx +8 -62
  29. package/dist/eject-theme/components/OverviewGroup/index.tsx +46 -0
  30. package/dist/eject-theme/components/Steps/index.scss +1 -0
  31. package/dist/index.d.ts +2 -1
  32. package/dist/index.js +3 -4
  33. package/dist/node/PluginDriver.js +1 -1
  34. package/dist/node/auto-nav-sidebar/index.js +1 -1
  35. package/dist/node/auto-nav-sidebar/normalize.js +1 -1
  36. package/dist/node/auto-nav-sidebar/utils.js +1 -1
  37. package/dist/node/auto-nav-sidebar/walk.js +1 -1
  38. package/dist/node/constants.js +1 -1
  39. package/dist/node/eject.js +1 -0
  40. package/dist/node/initRsbuild.js +6 -6
  41. package/dist/node/last-updated/index.js +1 -1
  42. package/dist/node/mdx/{loader.7c249a26.js → loader.15e0b2d2.js} +0 -5
  43. package/dist/node/mdx/options.js +2 -2
  44. package/dist/node/mdx/processor.js +1 -1
  45. package/dist/node/mdx/rehypePlugins/codeMeta.js +1 -1
  46. package/dist/node/mdx/rehypePlugins/headerAnchor.js +2 -3
  47. package/dist/node/mdx/rehypePlugins/shiki.js +1 -1
  48. package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +1 -2
  49. package/dist/node/mdx/remarkPlugins/image.js +1 -3
  50. package/dist/node/mdx/remarkPlugins/link.js +1 -2
  51. package/dist/node/mdx/remarkPlugins/toc.d.ts +4 -3
  52. package/dist/node/mdx/remarkPlugins/toc.js +14 -11
  53. package/dist/node/route/RoutePage.d.ts +3 -1
  54. package/dist/node/route/RoutePage.js +4 -0
  55. package/dist/node/route/RouteService.js +2 -2
  56. package/dist/node/route/extractPageData.d.ts +5 -0
  57. package/dist/node/route/extractPageData.js +88 -58
  58. package/dist/node/route/normalizeRoutePath.js +2 -2
  59. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.d.ts +21 -0
  60. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.js +21 -0
  61. package/dist/node/runtimeModule/i18n.js +4 -3
  62. package/dist/node/runtimeModule/pageData/createPageData.js +9 -6
  63. package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +20 -14
  64. package/dist/node/runtimeModule/siteData/createSiteData.js +2 -1
  65. package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
  66. package/dist/node/serve.js +1 -1
  67. package/dist/node/ssg/renderPage.js +1 -1
  68. package/dist/node/ssg/renderPageWorker.js +1 -1
  69. package/dist/node/ssg/renderPages.js +7 -3
  70. package/dist/node/ssg/rsbuildPluginSSG.js +1 -1
  71. package/dist/node/ssg/ssgEnv.js +1 -1
  72. package/dist/node/ssg-md/llms/emitLlmsTxt.js +2 -2
  73. package/dist/node/ssg-md/llms/llmsTxt.js +12 -2
  74. package/dist/node/ssg-md/remarkSplitMdx.js +2 -2
  75. package/dist/node/ssg-md/renderPage.js +1 -1
  76. package/dist/node/ssg-md/renderPages.js +1 -1
  77. package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -1
  78. package/dist/node/utils/createHash.js +1 -1
  79. package/dist/node/utils/flattenMdxContent.js +2 -3
  80. package/dist/node/utils/getPageKey.js +1 -1
  81. package/dist/node/utils/normalizePath.js +1 -1
  82. package/dist/node/utils/reactAlias.js +1 -1
  83. package/dist/runtime/Content.d.ts +4 -0
  84. package/dist/runtime/Content.js +18 -0
  85. package/dist/runtime/NoSSR.d.ts +3 -0
  86. package/dist/runtime/NoSSR.js +14 -0
  87. package/dist/runtime/getSidebarDataGroup.test.js +68 -0
  88. package/dist/runtime/hooks/useActiveMatcher.d.ts +1 -0
  89. package/dist/runtime/hooks/useActiveMatcher.js +14 -0
  90. package/dist/runtime/hooks/useDark.d.ts +7 -0
  91. package/dist/runtime/hooks/useDark.js +7 -0
  92. package/dist/runtime/hooks/useFrontmatter.d.ts +4 -0
  93. package/dist/runtime/hooks/useFrontmatter.js +9 -0
  94. package/dist/runtime/hooks/useI18n.d.ts +2 -0
  95. package/dist/runtime/hooks/useI18n.js +14 -0
  96. package/dist/runtime/hooks/useLang.d.ts +1 -0
  97. package/dist/runtime/hooks/useLang.js +6 -0
  98. package/dist/runtime/hooks/useLocaleSiteData.d.ts +18 -0
  99. package/dist/runtime/hooks/useLocaleSiteData.js +20 -0
  100. package/dist/runtime/hooks/useNav.d.ts +1 -0
  101. package/dist/runtime/hooks/useNav.js +12 -0
  102. package/dist/runtime/hooks/usePage.d.ts +10 -0
  103. package/dist/runtime/hooks/usePage.js +9 -0
  104. package/dist/runtime/hooks/usePageData.d.ts +5 -0
  105. package/dist/runtime/hooks/usePageData.js +16 -0
  106. package/dist/runtime/hooks/usePages.d.ts +4 -0
  107. package/dist/runtime/hooks/usePages.js +7 -0
  108. package/dist/runtime/hooks/useSidebar.d.ts +16 -0
  109. package/dist/runtime/hooks/useSidebar.js +67 -0
  110. package/dist/runtime/hooks/useSite.d.ts +4 -0
  111. package/dist/runtime/hooks/useSite.js +7 -0
  112. package/dist/runtime/hooks/useVersion.d.ts +1 -0
  113. package/dist/runtime/hooks/useVersion.js +6 -0
  114. package/dist/runtime/hooks/useWindowSize.d.ts +9 -0
  115. package/dist/runtime/hooks/useWindowSize.js +31 -0
  116. package/dist/runtime/hooks/useWindowSize.test.js +36 -0
  117. package/dist/runtime/index.d.ts +21 -0
  118. package/dist/runtime/index.js +22 -0
  119. package/dist/runtime/route.d.ts +36 -0
  120. package/dist/runtime/route.js +53 -0
  121. package/dist/runtime/route.test.js +154 -0
  122. package/dist/runtime/ssrMdServerEntry.js +1 -1
  123. package/dist/runtime/utils.d.ts +12 -0
  124. package/dist/runtime/utils.js +34 -0
  125. package/dist/runtime/utils.test.js +34 -0
  126. package/dist/theme/components/Callout/index.css +6 -6
  127. package/dist/theme/components/CodeBlock/index.js +1 -1
  128. package/dist/theme/components/DocContent/docComponents/title.js +25 -5
  129. package/dist/theme/components/FallbackHeading/index.js +4 -1
  130. package/dist/theme/components/HomeBackground/useNavTransparent.js +1 -1
  131. package/dist/theme/components/HomeHero/index.css +16 -10
  132. package/dist/theme/components/HomeHero/index.js +10 -3
  133. package/dist/theme/components/Llms/LlmsContainer.css +7 -0
  134. package/dist/theme/components/Llms/LlmsContainer.d.ts +5 -0
  135. package/dist/theme/components/Llms/LlmsContainer.js +9 -0
  136. package/dist/theme/components/Llms/LlmsCopyButton.css +57 -0
  137. package/dist/theme/components/Llms/LlmsCopyButton.d.ts +20 -0
  138. package/dist/theme/components/Llms/LlmsCopyButton.js +73 -0
  139. package/dist/theme/components/Llms/LlmsCopyButton.js.LICENSE.txt +5 -0
  140. package/dist/theme/components/Llms/LlmsViewOptions.css +93 -0
  141. package/dist/theme/components/Llms/LlmsViewOptions.d.ts +34 -0
  142. package/dist/theme/components/Llms/LlmsViewOptions.js +206 -0
  143. package/dist/theme/components/Llms/LlmsViewOptions.js.LICENSE.txt +5 -0
  144. package/dist/theme/components/Llms/index.css +32 -0
  145. package/dist/theme/components/Llms/index.d.ts +4 -0
  146. package/dist/theme/components/Llms/index.js +5 -0
  147. package/dist/theme/components/Llms/useMdUrl.d.ts +6 -0
  148. package/dist/theme/components/Llms/useMdUrl.js +15 -0
  149. package/dist/theme/components/Nav/index.css +1 -0
  150. package/dist/theme/components/Nav/index.js +1 -2
  151. package/dist/theme/components/{Nav/NavTitle.d.ts → NavTitle/index.d.ts} +1 -1
  152. package/dist/theme/components/{Nav/NavTitle.js → NavTitle/index.js} +11 -6
  153. package/dist/theme/components/Overview/index.js +11 -43
  154. package/dist/theme/components/OverviewGroup/index.js +33 -0
  155. package/dist/theme/components/PageTabs/index.css +1 -1
  156. package/dist/theme/components/Steps/index.css +1 -0
  157. package/dist/theme/components/Tabs/index.css +4 -4
  158. package/dist/theme/hooks/useDynamicToc.d.ts +2 -0
  159. package/dist/theme/hooks/useDynamicToc.js +3 -1
  160. package/dist/theme/index.d.ts +3 -1
  161. package/dist/theme/index.js +4 -2
  162. package/dist/theme/layout/Layout/index.js +1 -1
  163. package/dist/theme/logic/useScrollAfterNav.js +2 -2
  164. package/dist/theme/logic/useScrollReset.js +2 -2
  165. package/dist/theme/logic/{useAppearance.d.ts → useThemeState.d.ts} +4 -1
  166. package/dist/theme/logic/useThemeState.js +50 -0
  167. package/dist/theme/styles/scrollbar.css +14 -2
  168. package/package.json +18 -20
  169. package/static/MediumZoom.tsx +1 -1
  170. package/dist/4669.69cb6b18.js +0 -1
  171. package/dist/8813.4b28f4bb.js +0 -1
  172. package/dist/9643.2dff683e.js +0 -4
  173. package/dist/cli/config/index.d.ts +0 -2
  174. package/dist/runtime.72d450ac.js +0 -1
  175. package/dist/runtime.d.ts +0 -2
  176. package/dist/runtime.js +0 -3
  177. package/dist/theme/logic/useAppearance.js +0 -64
  178. /package/dist/{cli/config/index.js → config/defineConfig.js} +0 -0
  179. /package/dist/{cli/config → config}/loadConfigFile.d.ts +0 -0
  180. /package/dist/eject-theme/components/{Nav/NavTitle.scss → NavTitle/index.scss} +0 -0
  181. /package/dist/theme/components/{Nav/NavTitle.css → NavTitle/index.css} +0 -0
@@ -7,10 +7,10 @@ import { Buffer } from "node:buffer";
7
7
  import node_child_process, { ChildProcess } from "node:child_process";
8
8
  import { setTimeout as promises_setTimeout } from "node:timers/promises";
9
9
  import { debuglog } from "node:util";
10
- import { node_process, node_os, constants } from "./9643.2dff683e.js";
10
+ import { node_process, node_os, constants } from "./9348.1beb3e25.js";
11
11
  import { node_path } from "./6289.29817fb4.js";
12
- import { node_url } from "./5485.9fc7f63d.js";
13
- import { createWriteStream, createReadStream, readFileSync } from "./3521.9eb6b114.js";
12
+ import { node_url } from "./5485.7586c86a.js";
13
+ import { createWriteStream, createReadStream, readFileSync } from "./7786.421b464f.js";
14
14
  __webpack_require__.add({
15
15
  "../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js" (module, __unused_rspack_exports, __webpack_require__) {
16
16
  const cp = __webpack_require__("child_process");
@@ -1,5 +1,5 @@
1
1
  var package_namespaceObject = {
2
- rE: "2.0.0-rc.4"
2
+ rE: "2.0.0-rc.6"
3
3
  };
4
4
  async function pMap(iterable, mapper, { concurrency = 1 / 0, stopOnError = true, signal } = {}) {
5
5
  return new Promise((resolve_, reject_)=>{
@@ -48,8 +48,8 @@ export { DEFAULT_CONFIG_EXTENSIONS, DEFAULT_CONFIG_NAME, DEFAULT_PAGE_EXTENSIONS
48
48
  export { glob } from "tinyglobby";
49
49
  export { PLUGIN_REACT_NAME, pluginReact } from "@rsbuild/plugin-react";
50
50
  export { chunk, groupBy } from "lodash-es";
51
- export { compile } from "@rspress/mdx-rs";
52
- export { htmlToText } from "html-to-text";
51
+ export { default as remark_parse } from "remark-parse";
52
+ export { remove } from "unist-util-remove";
53
53
  export { createReadStream, createWriteStream, default as node_fs, readFileSync } from "node:fs";
54
54
  export { mergeRsbuildConfig, rspack as core_rspack } from "@rsbuild/core";
55
55
  export { createHash } from "node:crypto";
@@ -0,0 +1,11 @@
1
+ export { MDX_OR_MD_REGEXP, RSPRESS_TEMP_DIR, SEARCH_INDEX_NAME, addLeadingSlash, addTrailingSlash, getSidebarDataGroup, isDebugMode, isExternalUrl, isProduction, normalizeHref, normalizePosixPath, parseUrl, removeLeadingSlash, removeTrailingSlash, slash, withBase } from "@rspress/shared";
2
+ export { extractTextAndId, getIconUrlPath, getNodeAttribute, loadFrontMatter, mergeDocConfig } from "@rspress/shared/node-utils";
3
+ export { constants, default as node_os } from "node:os";
4
+ export { cwd, default as node_process } from "node:process";
5
+ export { default as remark_gfm } from "remark-gfm";
6
+ export { default as remark_stringify } from "remark-stringify";
7
+ export { unified } from "unified";
8
+ export { visit } from "unist-util-visit";
9
+ export { default as github_slugger } from "github-slugger";
10
+ export { visitChildren } from "unist-util-visit-children";
11
+ export { createProcessor, nodeTypes } from "@mdx-js/mdx";
@@ -100,7 +100,7 @@ async function renderToMarkdownString(element) {
100
100
  const root = reconciler.createContainer(container, 1, null, false, false, '', (error, info)=>{
101
101
  if (process.env.DEBUG) {
102
102
  console.error('Reconciler Error:', error, info);
103
- const message = 'Reconciler Error:' + error.message;
103
+ const message = `Reconciler Error:${error.message}`;
104
104
  throw new Error(message);
105
105
  }
106
106
  }, ()=>{}, (...args)=>{
package/dist/cli/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { node_path, logger, join, picocolors } from "../6289.29817fb4.js";
2
2
  import { chokidar, cac } from "./index.44f3184c.js";
3
- import { package_namespaceObject } from "../5485.9fc7f63d.js";
4
- import { loadConfigFile, resolveDocRoot } from "./config/loadConfigFile.js";
3
+ import { package_namespaceObject } from "../5485.7586c86a.js";
4
+ import { loadConfigFile, resolveDocRoot } from "../config/loadConfigFile.js";
5
5
  import { dev } from "../node/dev.js";
6
6
  import { PUBLIC_DIR } from "../node/constants.js";
7
7
  import { build } from "../node/build.js";
@@ -0,0 +1,40 @@
1
+ import type { UserConfig } from '@rspress/shared';
2
+ /**
3
+ * A function that returns a Promise resolving to a UserConfig.
4
+ * Use this type when you need to perform async operations during configuration,
5
+ * such as fetching data or reading files.
6
+ */
7
+ export type UserConfigAsyncFn = () => Promise<UserConfig>;
8
+ /**
9
+ * Define a static Rspress configuration object.
10
+ * @param config - The Rspress configuration object.
11
+ * @returns The same configuration object (enables type checking and IDE autocompletion).
12
+ * @example
13
+ * ```ts
14
+ * import { defineConfig } from '@rspress/core';
15
+ *
16
+ * export default defineConfig({
17
+ * title: 'My Site',
18
+ * });
19
+ * ```
20
+ */
21
+ export declare function defineConfig(config: UserConfig): UserConfig;
22
+ /**
23
+ * Define an async Rspress configuration function.
24
+ * Use this overload when you need to perform async operations during configuration,
25
+ * such as fetching remote data, reading files, or dynamically generating config.
26
+ * @param config - An async function that returns the Rspress configuration.
27
+ * @returns The same async function (enables type checking and IDE autocompletion).
28
+ * @example
29
+ * ```ts
30
+ * import { defineConfig } from '@rspress/core';
31
+ *
32
+ * export default defineConfig(async () => {
33
+ * const remoteConfig = await fetchConfig();
34
+ * return {
35
+ * title: remoteConfig.title,
36
+ * };
37
+ * });
38
+ * ```
39
+ */
40
+ export declare function defineConfig(config: UserConfigAsyncFn): UserConfigAsyncFn;
@@ -1,5 +1,5 @@
1
- import { node_fs, DEFAULT_CONFIG_EXTENSIONS, DEFAULT_CONFIG_NAME } from "../../3521.9eb6b114.js";
2
- import { node_path, logger } from "../../6289.29817fb4.js";
1
+ import { node_fs, DEFAULT_CONFIG_EXTENSIONS, DEFAULT_CONFIG_NAME } from "../7786.421b464f.js";
2
+ import { node_path, logger } from "../6289.29817fb4.js";
3
3
  const findConfig = (basePath)=>DEFAULT_CONFIG_EXTENSIONS.map((ext)=>basePath + ext).find(node_fs.existsSync);
4
4
  async function loadConfigFile(customConfigFile) {
5
5
  const baseDir = process.cwd();
@@ -120,7 +120,7 @@
120
120
  }
121
121
 
122
122
  // inline code
123
- :not(pre, div) > code {
123
+ :not(pre) > code {
124
124
  color: var(--rp-container-note-text);
125
125
  background-color: var(--rp-container-note-code-bg);
126
126
  }
@@ -143,7 +143,7 @@
143
143
  }
144
144
 
145
145
  // inline code
146
- :not(pre, div) > code {
146
+ :not(pre) > code {
147
147
  color: var(--rp-container-tip-text);
148
148
  background-color: var(--rp-container-tip-code-bg);
149
149
  }
@@ -166,7 +166,7 @@
166
166
  }
167
167
 
168
168
  // inline code
169
- :not(pre, div) > code {
169
+ :not(pre) > code {
170
170
  color: var(--rp-container-info-text);
171
171
  background-color: var(--rp-container-info-code-bg);
172
172
  }
@@ -189,7 +189,7 @@
189
189
  }
190
190
 
191
191
  // inline code
192
- :not(pre, div) > code {
192
+ :not(pre) > code {
193
193
  color: var(--rp-container-warning-text);
194
194
  background-color: var(--rp-container-warning-code-bg);
195
195
  }
@@ -213,7 +213,7 @@
213
213
  }
214
214
 
215
215
  // inline code
216
- :not(pre, div) > code {
216
+ :not(pre) > code {
217
217
  color: var(--rp-container-danger-text);
218
218
  background-color: var(--rp-container-danger-code-bg);
219
219
  }
@@ -236,7 +236,7 @@
236
236
  }
237
237
 
238
238
  // inline code
239
- :not(pre, div) > code {
239
+ :not(pre) > code {
240
240
  color: var(--rp-container-details-text);
241
241
  background-color: var(--rp-container-details-code-bg);
242
242
  }
@@ -92,7 +92,7 @@ export function CodeBlock({
92
92
  )}
93
93
  >
94
94
  <div
95
- className="rp-codeblock__content__scroll-container rp-scrollbar"
95
+ className="rp-codeblock__content__scroll-container rp-scrollbar rp-scrollbar--always"
96
96
  ref={copyElementRef}
97
97
  >
98
98
  {children}
@@ -1,9 +1,28 @@
1
+ import { useFrontmatter } from '@rspress/core/runtime';
2
+ import { LlmsContainer, LlmsCopyButton, LlmsViewOptions, Tag } from '@theme';
1
3
  import clsx from 'clsx';
2
4
  import type React from 'react';
3
5
 
4
6
  export const H1 = (props: React.ComponentProps<'h1'>) => {
5
- const { className, ...rest } = props;
6
- return <h1 className={clsx('rp-toc-include', className)} {...rest} />;
7
+ const { className, children, ...rest } = props;
8
+
9
+ const {
10
+ frontmatter: { tag },
11
+ } = useFrontmatter();
12
+
13
+ return (
14
+ <>
15
+ <h1 className={clsx('rp-toc-include', className)} {...rest}>
16
+ {children} <Tag tag={tag} />
17
+ </h1>
18
+ {process.env.ENABLE_LLMS_UI && (
19
+ <LlmsContainer>
20
+ <LlmsCopyButton />
21
+ <LlmsViewOptions />
22
+ </LlmsContainer>
23
+ )}
24
+ </>
25
+ );
7
26
  };
8
27
 
9
28
  export const H2 = (props: React.ComponentProps<'h2'>) => {
@@ -28,6 +28,10 @@ export function FallbackHeading({
28
28
  level: 1 | 2 | 3 | 4 | 5 | 6;
29
29
  title: string;
30
30
  }) {
31
+ if (process.env.__SSR_MD__) {
32
+ return <>{`${'#'.repeat(level)} ${title}\n\n`}</>;
33
+ }
34
+
31
35
  const titleSlug = title && slug(title.trim());
32
36
 
33
37
  const Element = useMemo(() => {
@@ -36,7 +36,8 @@ export const useNavTransparent = () => {
36
36
 
37
37
  return (
38
38
  <style>
39
- {'body:not(.notTopArrived) .rp-nav {background: transparent !important; border-bottom: none !important;}' +
39
+ {'body:not(.notTopArrived) ' +
40
+ '.rp-nav {background: transparent !important; border-bottom: 1px solid transparent !important;}' +
40
41
  // TODO: discussion
41
42
  '.rp-nav {background: color-mix(in srgb,var(--rp-c-bg) 60%,transparent);backdrop-filter: blur(25px);}'}
42
43
  </style>
@@ -78,11 +78,19 @@
78
78
  font-size: 0.875rem;
79
79
  font-weight: 500;
80
80
  color: var(--rp-c-text-0);
81
+ text-decoration: none;
82
+ transition:
83
+ background 0.2s,
84
+ border-color 0.2s;
81
85
 
82
86
  &:hover {
83
87
  background: var(--rp-c-bg-mute);
84
88
  cursor: pointer;
85
89
  }
90
+
91
+ &:is(a):hover {
92
+ border-color: var(--rp-c-brand);
93
+ }
86
94
  }
87
95
 
88
96
  &__title {
@@ -1,6 +1,6 @@
1
1
  import type { FrontMatterMeta } from '@rspress/core';
2
2
  import { normalizeImagePath, useFrontmatter } from '@rspress/core/runtime';
3
- import { Button, renderHtmlOrText } from '@theme';
3
+ import { Button, Link, renderHtmlOrText } from '@theme';
4
4
 
5
5
  import './index.scss';
6
6
  import clsx from 'clsx';
@@ -39,7 +39,16 @@ function HomeHero({ beforeHeroActions, afterHeroActions }: HomeHeroProps) {
39
39
  className={clsx('rp-home-hero', { 'rp-home-hero--no-image': !hasImage })}
40
40
  >
41
41
  <div className="rp-home-hero__container">
42
- {hero.badge && <div className="rp-home-hero__badge">{hero.badge}</div>}
42
+ {hero.badge &&
43
+ (typeof hero.badge === 'string' ? (
44
+ <div className="rp-home-hero__badge">{hero.badge}</div>
45
+ ) : hero.badge.link ? (
46
+ <Link href={hero.badge.link} className="rp-home-hero__badge">
47
+ {hero.badge.text}
48
+ </Link>
49
+ ) : (
50
+ <div className="rp-home-hero__badge">{hero.badge.text}</div>
51
+ ))}
43
52
  <div className="rp-home-hero__content">
44
53
  <div className="rp-home-hero__title">
45
54
  <span
@@ -0,0 +1,6 @@
1
+ .rp-llms-container {
2
+ display: flex;
3
+ align-items: center;
4
+ gap: 8px;
5
+ margin-bottom: 20px;
6
+ }
@@ -0,0 +1,9 @@
1
+ import type React from 'react';
2
+ import './LlmsContainer.scss';
3
+
4
+ export interface LlmsContainerProps
5
+ extends React.HTMLAttributes<HTMLDivElement> {}
6
+
7
+ export function LlmsContainer(props: LlmsContainerProps) {
8
+ return <div {...props} className={'rp-not-doc rp-llms-container'} />;
9
+ }
@@ -0,0 +1,57 @@
1
+ .rp-llms-copy-button {
2
+ position: relative;
3
+ overflow: hidden;
4
+
5
+ &--loading.rp-llms-copy-button {
6
+ background: var(--rp-c-bg-mute);
7
+ opacity: 0.7;
8
+ cursor: wait;
9
+ }
10
+
11
+ &--success.rp-llms-copy-button {
12
+ color: var(--rp-c-green-1, #10b981);
13
+ border-color: var(--rp-c-green-1, #10b981);
14
+ background: var(--rp-c-bg-soft);
15
+ }
16
+ }
17
+
18
+ .rp-llms-copy-button--success .rp-llms-copy-button__icon-copy {
19
+ opacity: 0;
20
+ transform: translate(-50%, -50%) scale(0.5);
21
+ }
22
+
23
+ .rp-llms-copy-button--success .rp-llms-copy-button__icon-success {
24
+ opacity: 1;
25
+ visibility: visible;
26
+ transform: translate(-50%, -50%) scale(1);
27
+ }
28
+
29
+ .rp-llms-copy-button__icon-wrapper {
30
+ width: 16px;
31
+ height: 16px;
32
+ position: relative;
33
+ }
34
+
35
+ .rp-llms-copy-button__icon-copy {
36
+ width: 16px;
37
+ height: 16px;
38
+ position: absolute;
39
+ top: 50%;
40
+ left: 50%;
41
+ transform: translate(-50%, -50%) scale(1);
42
+ transition: all 0.2s ease;
43
+ }
44
+
45
+ .rp-llms-copy-button__icon-success {
46
+ width: 16px;
47
+ height: 16px;
48
+ position: absolute;
49
+ top: 50%;
50
+ left: 50%;
51
+ color: var(--rp-c-green-1, #10b981);
52
+
53
+ visibility: hidden;
54
+ opacity: 0;
55
+ transform: translate(-50%, -50%) scale(0.5);
56
+ transition: all 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28);
57
+ }
@@ -0,0 +1,94 @@
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 } from '@rspress/core/runtime';
7
+ import { IconCopy, IconSuccess } from '@theme';
8
+ import { useCallback, useRef, useState } from 'react';
9
+ import './index.scss';
10
+ import './LlmsCopyButton.scss';
11
+ import { useMdUrl } from './useMdUrl';
12
+
13
+ export interface LlmsCopyButtonProps
14
+ extends React.ButtonHTMLAttributes<HTMLButtonElement> {
15
+ /**
16
+ * Text by language, used with `useLang`.
17
+ * @default en: 'Copy Markdown', zh: '\u590d\u5236 Markdown'
18
+ */
19
+ textByLang?: Record<string, string>;
20
+ /**
21
+ * Priority is higher than textByLang
22
+ * @default ''
23
+ */
24
+ text?: string;
25
+ /**
26
+ * Overrides the default click handler.
27
+ * If provided, the default copy to clipboard functionality will not be executed.
28
+ */
29
+ onClick?: React.MouseEventHandler<HTMLButtonElement>;
30
+ }
31
+
32
+ const cache = new Map<string, string>();
33
+
34
+ export function LlmsCopyButton(props: LlmsCopyButtonProps) {
35
+ const { onClick, ...otherProps } = props;
36
+ const t = useI18n();
37
+
38
+ const { pathname } = useMdUrl();
39
+
40
+ const [isLoading, setLoading] = useState(false);
41
+ const [isFinished, setFinished] = useState(false);
42
+
43
+ const timer = useRef<number | null>(null);
44
+ const handleClick = useCallback(async () => {
45
+ setLoading(true);
46
+
47
+ const url = pathname;
48
+ try {
49
+ const content: string =
50
+ cache.get(url) ?? (await fetch(url).then(res => res.text()));
51
+
52
+ cache.set(url, content);
53
+ await navigator.clipboard.writeText(content);
54
+ } finally {
55
+ setLoading(false);
56
+ setFinished(true);
57
+ if (timer.current) {
58
+ clearTimeout(timer.current);
59
+ timer.current = null;
60
+ }
61
+ timer.current = window.setTimeout(() => {
62
+ setFinished(false);
63
+ timer.current = null;
64
+ }, 500);
65
+ }
66
+ }, [pathname]);
67
+
68
+ if (!pathname) {
69
+ return <></>;
70
+ }
71
+
72
+ return (
73
+ <button
74
+ {...otherProps}
75
+ disabled={isLoading}
76
+ className={[
77
+ 'rp-not-doc',
78
+ 'rp-llms-button',
79
+ 'rp-llms-copy-button',
80
+ isLoading ? 'rp-llms-copy-button--loading' : '',
81
+ isFinished ? 'rp-llms-copy-button--success' : '',
82
+ ]
83
+ .filter(Boolean)
84
+ .join(' ')}
85
+ onClick={onClick ?? handleClick}
86
+ >
87
+ <div className="rp-llms-copy-button__icon-wrapper">
88
+ <IconSuccess className="rp-llms-copy-button__icon-success" />
89
+ <IconCopy className="rp-llms-copy-button__icon-copy" />
90
+ </div>
91
+ <span>{t('copyMarkdownText')}</span>
92
+ </button>
93
+ );
94
+ }
@@ -0,0 +1,98 @@
1
+ .rp-llms-view-options__trigger {
2
+ position: relative;
3
+
4
+ &--active {
5
+ background: var(--rp-c-bg-mute);
6
+ color: var(--rp-c-text-1);
7
+ border-color: var(--rp-c-divider);
8
+ }
9
+ }
10
+
11
+ .rp-llms-view-options__arrow {
12
+ transition: transform 0.2s ease;
13
+ &--rotated {
14
+ transform: rotate(180deg);
15
+ }
16
+ }
17
+
18
+ .rp-llms-view-options__menu {
19
+ width: max-content;
20
+ min-width: 220px;
21
+ position: absolute;
22
+ top: calc(100% + 6px);
23
+ left: 0;
24
+ z-index: 100;
25
+
26
+ display: flex;
27
+ padding: 6px;
28
+ flex-direction: column;
29
+ align-items: flex-start;
30
+
31
+ border-radius: 10px;
32
+ border: 1px solid var(--rp-c-divider-light);
33
+ background: var(--rp-c-bg);
34
+ color: var(--rp-c-text-1);
35
+
36
+ box-shadow:
37
+ 0 4px 20px -4px rgba(0, 0, 0, 0.15),
38
+ 0 0 2px 0 rgba(0, 0, 0, 0.05);
39
+ transform-origin: top left;
40
+ animation: dropdownIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
41
+ }
42
+
43
+ // dropdownIn
44
+ @keyframes dropdownIn {
45
+ from {
46
+ opacity: 0;
47
+ transform: translateY(-8px) scale(0.96);
48
+ }
49
+ to {
50
+ opacity: 1;
51
+ transform: translateY(0) scale(1);
52
+ }
53
+ }
54
+
55
+ .rp-llms-view-options__menu-item {
56
+ display: flex;
57
+ align-items: center;
58
+ gap: 10px;
59
+ width: 100%;
60
+ padding: 8px 10px;
61
+ border: none;
62
+ background: transparent;
63
+ text-align: left;
64
+ cursor: pointer;
65
+ font-size: 14px;
66
+ font-weight: 500;
67
+ border-radius: 6px;
68
+ color: var(--rp-c-text-2);
69
+ transition:
70
+ background 0.2s,
71
+ color 0.2s;
72
+
73
+ &:hover {
74
+ background: var(--rp-c-bg-mute);
75
+ color: var(--rp-c-text-1);
76
+ text-decoration: none;
77
+ }
78
+
79
+ &:active {
80
+ background: var(--rp-c-bg-soft);
81
+ }
82
+ }
83
+
84
+ .rp-llms-view-options__item-icon {
85
+ display: inline-flex;
86
+ align-items: center;
87
+ justify-content: center;
88
+ width: 16px;
89
+ height: 16px;
90
+ font-size: 16px;
91
+ }
92
+
93
+ .rp-llms-view-options__external-icon {
94
+ margin-left: auto;
95
+ width: 16px;
96
+ height: 16px;
97
+ font-size: 16px;
98
+ }