@rspress/core 2.0.18 → 2.0.19

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 (143) hide show
  1. package/dist/{4538.js → 4538~0.js} +1 -1
  2. package/dist/6305~0.js +3007 -0
  3. package/dist/{3553.js → 8472~0.js} +2 -2
  4. package/dist/{0~execa.js → 864~0.js} +11 -11
  5. package/dist/cli/index.js +13 -40
  6. package/dist/config/defineConfig.d.ts +15 -15
  7. package/dist/config/loadConfigFile.js +1 -1
  8. package/dist/eject-theme/components/HoverGroup/index.scss +16 -0
  9. package/dist/eject-theme/components/HoverGroup/index.tsx +22 -1
  10. package/dist/eject-theme/components/Llms/LlmsCopyButton.tsx +2 -6
  11. package/dist/eject-theme/components/Llms/LlmsCopyRow.tsx +2 -5
  12. package/dist/eject-theme/components/Llms/LlmsHint.test.tsx +104 -0
  13. package/dist/eject-theme/components/Llms/LlmsHint.tsx +70 -0
  14. package/dist/eject-theme/components/Llms/getLlmsCopyContent.test.ts +21 -0
  15. package/dist/eject-theme/components/Llms/getLlmsCopyContent.ts +20 -0
  16. package/dist/eject-theme/components/Llms/index.tsx +1 -1
  17. package/dist/eject-theme/components/Nav/NavMenu.scss +16 -0
  18. package/dist/eject-theme/components/Nav/NavMenu.tsx +12 -0
  19. package/dist/eject-theme/components/NavScreen/NavScreenMenuItem.scss +18 -2
  20. package/dist/eject-theme/components/NavScreen/NavScreenMenuItem.tsx +27 -19
  21. package/dist/eject-theme/components/NavScreen/index.scss +4 -0
  22. package/dist/eject-theme/components/Outline/index.scss +4 -0
  23. package/dist/eject-theme/components/Sidebar/SidebarGroup.tsx +3 -0
  24. package/dist/eject-theme/components/Sidebar/SidebarItem.scss +16 -0
  25. package/dist/eject-theme/components/Sidebar/SidebarItem.test.tsx +51 -0
  26. package/dist/eject-theme/components/Sidebar/SidebarItem.tsx +10 -1
  27. package/dist/eject-theme/components/Sidebar/SidebarSectionHeader.scss +15 -0
  28. package/dist/eject-theme/components/Sidebar/SidebarSectionHeader.tsx +6 -1
  29. package/dist/eject-theme/components/Sidebar/index.tsx +1 -0
  30. package/dist/index.js +1 -1
  31. package/dist/node/PluginDriver.js +1 -1
  32. package/dist/node/auto-nav-sidebar/index.js +1 -1
  33. package/dist/node/auto-nav-sidebar/locales.js +1 -1
  34. package/dist/node/auto-nav-sidebar/normalize.js +39 -10
  35. package/dist/node/auto-nav-sidebar/type.d.ts +7 -0
  36. package/dist/node/auto-nav-sidebar/utils.d.ts +1 -0
  37. package/dist/node/auto-nav-sidebar/utils.js +2 -1
  38. package/dist/node/auto-nav-sidebar/walk.js +1 -1
  39. package/dist/node/constants.d.ts +2 -1
  40. package/dist/node/constants.js +50 -2
  41. package/dist/node/dev.d.ts +2 -1
  42. package/dist/node/dev.js +7 -2
  43. package/dist/node/eject.js +3 -3
  44. package/dist/node/initRsbuild.d.ts +6 -2
  45. package/dist/node/initRsbuild.js +35 -11
  46. package/dist/node/last-updated/index.js +112 -15
  47. package/dist/node/logger/hint.js +2 -2
  48. package/dist/node/mdx/options.js +1 -1
  49. package/dist/node/mdx/processor.js +1 -1
  50. package/dist/node/mdx/rehypePlugins/codeMeta.js +1 -1
  51. package/dist/node/mdx/rehypePlugins/headerAnchor.js +1 -1
  52. package/dist/node/mdx/rehypePlugins/shiki.js +1 -1
  53. package/dist/node/mdx/remarkPlugins/builtin.js +1 -1
  54. package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +3 -3
  55. package/dist/node/mdx/remarkPlugins/image.js +3 -3
  56. package/dist/node/mdx/remarkPlugins/link.js +3 -3
  57. package/dist/node/mdx/remarkPlugins/toc.js +1 -1
  58. package/dist/node/medium-zoom/index.js +1 -1
  59. package/dist/node/route/RoutePage.js +1 -1
  60. package/dist/node/route/RouteService.js +1 -1
  61. package/dist/node/route/extractPageData.js +3 -15
  62. package/dist/node/route/normalizeRoutePath.js +1 -1
  63. package/dist/node/runtimeModule/i18n.js +3 -3
  64. package/dist/node/runtimeModule/pageData/createPageData.js +1 -1
  65. package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
  66. package/dist/node/runtimeModule/searchHooks.js +1 -1
  67. package/dist/node/runtimeModule/siteData/createSiteData.js +1 -1
  68. package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
  69. package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +1 -1
  70. package/dist/node/serve.js +1 -1
  71. package/dist/node/ssg/alternateLinks.js +1 -1
  72. package/dist/node/ssg/htmlFile.js +1 -1
  73. package/dist/node/ssg/renderHtmlTemplate.js +1 -1
  74. package/dist/node/ssg/renderPage.js +3 -3
  75. package/dist/node/ssg/renderPageWorker.js +2 -2
  76. package/dist/node/ssg/renderPages.js +5 -5
  77. package/dist/node/ssg/rsbuildPluginSSG.js +1 -1
  78. package/dist/node/ssg/ssgEnv.js +1 -1
  79. package/dist/node/ssg-md/llms/emitLlmsTxt.js +1 -1
  80. package/dist/node/ssg-md/llms/llmsTxt.js +1 -1
  81. package/dist/node/ssg-md/remarkSplitMdx.js +8 -10
  82. package/dist/node/ssg-md/renderPage.js +3 -3
  83. package/dist/node/ssg-md/renderPages.js +4 -4
  84. package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -1
  85. package/dist/node/utils/checkLanguageParity.js +1 -1
  86. package/dist/node/utils/createHash.js +1 -1
  87. package/dist/node/utils/error.js +2 -2
  88. package/dist/node/utils/flattenMdxContent.js +1 -1
  89. package/dist/node/utils/fs.js +1 -1
  90. package/dist/node/utils/getPageKey.js +1 -1
  91. package/dist/node/utils/normalizePath.js +1 -1
  92. package/dist/node/utils/reactAlias.js +3 -3
  93. package/dist/runtime/App.js +7 -4
  94. package/dist/runtime/index.d.ts +1 -0
  95. package/dist/runtime/index.js +1 -0
  96. package/dist/runtime/reactDom.d.ts +19 -0
  97. package/dist/runtime/reactDom.js +5 -0
  98. package/dist/theme/components/HoverGroup/index.css +15 -0
  99. package/dist/theme/components/HoverGroup/index.js +17 -1
  100. package/dist/theme/components/Llms/LlmsCopyButton.js +3 -4
  101. package/dist/theme/components/Llms/LlmsCopyRow.js +2 -3
  102. package/dist/theme/components/Llms/LlmsHint.d.ts +2 -0
  103. package/dist/theme/components/Llms/LlmsHint.js +40 -0
  104. package/dist/theme/components/Llms/getLlmsCopyContent.d.ts +1 -0
  105. package/dist/theme/components/Llms/getLlmsCopyContent.js +14 -0
  106. package/dist/theme/components/Llms/index.d.ts +1 -1
  107. package/dist/theme/components/Llms/index.js +1 -1
  108. package/dist/theme/components/Nav/NavMenu.css +15 -0
  109. package/dist/theme/components/Nav/NavMenu.js +8 -0
  110. package/dist/theme/components/NavScreen/NavScreenMenuItem.css +17 -2
  111. package/dist/theme/components/NavScreen/NavScreenMenuItem.js +21 -22
  112. package/dist/theme/components/NavScreen/index.css +4 -0
  113. package/dist/theme/components/Outline/index.css +4 -0
  114. package/dist/theme/components/Sidebar/SidebarGroup.js +4 -1
  115. package/dist/theme/components/Sidebar/SidebarItem.css +15 -0
  116. package/dist/theme/components/Sidebar/SidebarItem.d.ts +2 -1
  117. package/dist/theme/components/Sidebar/SidebarItem.js +7 -2
  118. package/dist/theme/components/Sidebar/SidebarSectionHeader.css +14 -0
  119. package/dist/theme/components/Sidebar/SidebarSectionHeader.d.ts +2 -1
  120. package/dist/theme/components/Sidebar/SidebarSectionHeader.js +12 -6
  121. package/dist/theme/components/Sidebar/index.js +1 -0
  122. package/dist/theme/index.d.ts +1 -2
  123. package/dist/theme/index.js +1 -2
  124. package/dist/theme/layout/Layout/index.js +1 -2
  125. package/meta-json-schema.json +33 -3
  126. package/nav-json-schema.json +9 -0
  127. package/package.json +15 -20
  128. package/dist/5871.js +0 -7275
  129. package/dist/5871.js.LICENSE.txt +0 -41
  130. package/dist/eject-theme/components/Llms/LlmsHiddenHint.test.tsx +0 -23
  131. package/dist/eject-theme/components/Llms/LlmsHiddenHint.tsx +0 -15
  132. package/dist/theme/components/Llms/LlmsHiddenHint.d.ts +0 -1
  133. package/dist/theme/components/Llms/LlmsHiddenHint.js +0 -18
  134. package/dist/theme/logic/useRedirect4FirstVisit.d.ts +0 -5
  135. package/dist/theme/logic/useRedirect4FirstVisit.js +0 -31
  136. /package/dist/{102.js → 102~0.js} +0 -0
  137. /package/dist/{5357.js → 5357~0.js} +0 -0
  138. /package/dist/{7748.js → 7748~0.js} +0 -0
  139. /package/dist/{0~8016.js → 8016~0.js} +0 -0
  140. /package/dist/{9857.js → 9857~0.js} +0 -0
  141. /package/dist/{9940.js → 9940~0.js} +0 -0
  142. /package/dist/{0~rslib-runtime.js → rslib-runtime~0.js} +0 -0
  143. /package/dist/{0~tinypool.js → tinypool~0.js} +0 -0
@@ -1,4 +1,4 @@
1
- import { normalizeHref, withSiteOrigin, logger, withBase } from "../../../5871.js";
1
+ import { normalizeHref, withSiteOrigin, logger, withBase } from "../../../6305~0.js";
2
2
  import { extractInfoFromFrontmatterWithAbsolutePath } from "../../auto-nav-sidebar/utils.js";
3
3
  function routePathToMdPath(routePath, base, siteOrigin) {
4
4
  let url = routePath;
@@ -1,9 +1,9 @@
1
- import { unified, visit, remark_gfm, remark_mdx, remark_stringify } from "../../9940.js";
1
+ import { unified, visit, remark_gfm, remark_mdx, remark_stringify } from "../../9940~0.js";
2
2
  function remarkSplitMdx(options = {}) {
3
3
  return (tree)=>{
4
4
  const newChildren = [];
5
- const { importMap, importNodes } = buildImportMap(tree);
6
- newChildren.push(...importNodes);
5
+ const { importMap, esmNodes } = collectEsmMetadata(tree);
6
+ newChildren.push(...esmNodes);
7
7
  for (const node of tree.children){
8
8
  if ('mdxjsEsm' === node.type) continue;
9
9
  if ('mdxFlowExpression' === node.type || 'mdxTextExpression' === node.type) {
@@ -212,10 +212,11 @@ function serializeNodeToMarkdown(node) {
212
212
  const result = processor.stringify(tempRoot);
213
213
  return result;
214
214
  }
215
- function buildImportMap(tree) {
215
+ function collectEsmMetadata(tree) {
216
216
  const importMap = new Map();
217
- const importNodes = new Set();
217
+ const esmNodes = new Set();
218
218
  visit(tree, 'mdxjsEsm', (node)=>{
219
+ esmNodes.add(node);
219
220
  const estree = node.data?.estree;
220
221
  if (!estree) return;
221
222
  for (const statement of estree.body){
@@ -223,16 +224,13 @@ function buildImportMap(tree) {
223
224
  const source = statement.source.value;
224
225
  for (const specifier of statement.specifiers){
225
226
  const localName = specifier.local?.name;
226
- if (localName) {
227
- importMap.set(localName, source);
228
- importNodes.add(node);
229
- }
227
+ if (localName) importMap.set(localName, source);
230
228
  }
231
229
  }
232
230
  });
233
231
  return {
234
232
  importMap,
235
- importNodes
233
+ esmNodes
236
234
  };
237
235
  }
238
236
  function shouldKeepJsxElement(nameField, importMap, options) {
@@ -1,6 +1,6 @@
1
- import { __webpack_require__ } from "../../0~rslib-runtime.js";
2
- import "../../4538.js";
3
- import { createHead, pathToFileURL, logger } from "../../5871.js";
1
+ import { __webpack_require__ } from "../../rslib-runtime~0.js";
2
+ import "../../4538~0.js";
3
+ import { createHead, pathToFileURL, logger } from "../../6305~0.js";
4
4
  import { hintSSGFailed } from "../logger/hint.js";
5
5
  const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
6
6
  var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
@@ -1,7 +1,7 @@
1
- import { __webpack_require__ } from "../../0~rslib-runtime.js";
2
- import "../../4538.js";
3
- import { logger } from "../../5871.js";
4
- import { pMap } from "../../3553.js";
1
+ import { __webpack_require__ } from "../../rslib-runtime~0.js";
2
+ import "../../4538~0.js";
3
+ import { logger } from "../../6305~0.js";
4
+ import { pMap } from "../../8472~0.js";
5
5
  import { renderPage } from "./renderPage.js";
6
6
  import { SSGConcurrency } from "../ssg/ssgEnv.js";
7
7
  const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
@@ -1,4 +1,4 @@
1
- import { writeFile, mkdir, rm, join, isDebugMode } from "../../5871.js";
1
+ import { writeFile, mkdir, rm, join, isDebugMode } from "../../6305~0.js";
2
2
  import { NODE_SSG_MD_BUNDLE_FOLDER, NODE_SSG_MD_BUNDLE_NAME } from "../constants.js";
3
3
  import { renderPages } from "./renderPages.js";
4
4
  import { emitLlmsTxt } from "./llms/emitLlmsTxt.js";
@@ -1,4 +1,4 @@
1
- import { node_path, logger, promises } from "../../5871.js";
1
+ import { node_path, logger, promises } from "../../6305~0.js";
2
2
  import { createError } from "./error.js";
3
3
  function normalizePath(filePath) {
4
4
  return filePath.split(node_path.sep).join('/');
@@ -1,4 +1,4 @@
1
- import { createHash as external_node_crypto_createHash } from "../../5871.js";
1
+ import { createHash as external_node_crypto_createHash } from "../../6305~0.js";
2
2
  function createHash(str, length = 8) {
3
3
  return external_node_crypto_createHash('sha256').update(str).digest('hex').slice(0, length);
4
4
  }
@@ -1,5 +1,5 @@
1
- import { __webpack_require__ } from "../../0~rslib-runtime.js";
2
- import "../../4538.js";
1
+ import { __webpack_require__ } from "../../rslib-runtime~0.js";
2
+ import "../../4538~0.js";
3
3
  const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
4
4
  var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
5
5
  function createError(message, maxStackLines = 5) {
@@ -1,4 +1,4 @@
1
- import { node_fs, node_path, core_rspack, logger, createProcessor, MDX_OR_MD_REGEXP } from "../../5871.js";
1
+ import { node_fs, node_path, core_rspack, logger, createProcessor, MDX_OR_MD_REGEXP } from "../../6305~0.js";
2
2
  import { createError } from "./error.js";
3
3
  import { importStatementRegex } from "../constants.js";
4
4
  const RspackResolveFactory = core_rspack.experiments.resolver.ResolverFactory;
@@ -1,4 +1,4 @@
1
- import { promises } from "../../4538.js";
1
+ import { promises } from "../../4538~0.js";
2
2
  async function pathExists(path) {
3
3
  try {
4
4
  await promises.access(path);
@@ -1,4 +1,4 @@
1
- import { removeLeadingSlash } from "../../5871.js";
1
+ import { removeLeadingSlash } from "../../6305~0.js";
2
2
  function getPageKey(route) {
3
3
  const cleanRoute = removeLeadingSlash(route);
4
4
  return cleanRoute.replace(/\//g, '_').replace(/\.[^.]+$/, '') || 'index';
@@ -1,4 +1,4 @@
1
- import { node_os, node_path } from "../../7748.js";
1
+ import { node_os, node_path } from "../../7748~0.js";
2
2
  const isWindows = 'win32' === node_os.platform();
3
3
  function slash(p) {
4
4
  return p.replace(/\\/g, '/');
@@ -1,6 +1,6 @@
1
- import { __webpack_require__ } from "../../0~rslib-runtime.js";
2
- import "../../4538.js";
3
- import { node_path, core_rspack, logger } from "../../5871.js";
1
+ import { __webpack_require__ } from "../../rslib-runtime~0.js";
2
+ import "../../4538~0.js";
3
+ import { node_path, core_rspack, logger } from "../../6305~0.js";
4
4
  import { pathExists, readJson } from "./fs.js";
5
5
  import { PACKAGE_ROOT } from "../constants.js";
6
6
  import { hintReactVersion } from "../logger/hint.js";
@@ -1,7 +1,7 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { PageContext, useLocation } from "@rspress/core/runtime";
3
3
  import { Layout, Root } from "@rspress/core/theme";
4
- import { LlmsHiddenHint } from "@rspress/core/theme-original";
4
+ import { LlmsHint } from "@rspress/core/theme-original";
5
5
  import react, { useContext, useLayoutEffect } from "react";
6
6
  import virtual_global_components from "virtual-global-components";
7
7
  import { consumeCachedPageData, initPageData, setCurrentPageData } from "./initPageData.js";
@@ -30,12 +30,15 @@ function App() {
30
30
  const GLOBAL_COMPONENTS_KEY = 'globalUIComponents';
31
31
  const query = new URLSearchParams(search);
32
32
  const hideGlobalUIComponents = false === frontmatter[GLOBAL_COMPONENTS_KEY] || "0" === query.get(GLOBAL_COMPONENTS_KEY);
33
- if (import.meta.env.SSG_MD) return /*#__PURE__*/ jsx(Root, {
34
- children: /*#__PURE__*/ jsx(Layout, {})
33
+ if (import.meta.env.SSG_MD) return /*#__PURE__*/ jsxs(Root, {
34
+ children: [
35
+ import.meta.env.ENABLE_LLMS_HINT && /*#__PURE__*/ jsx(LlmsHint, {}),
36
+ /*#__PURE__*/ jsx(Layout, {})
37
+ ]
35
38
  });
36
39
  return /*#__PURE__*/ jsxs(Root, {
37
40
  children: [
38
- import.meta.env.ENABLE_LLMS_HINT && /*#__PURE__*/ jsx(LlmsHiddenHint, {}),
41
+ import.meta.env.ENABLE_LLMS_HINT && /*#__PURE__*/ jsx(LlmsHint, {}),
39
42
  /*#__PURE__*/ jsx(Layout, {}),
40
43
  !hideGlobalUIComponents && virtual_global_components.map((componentInfo, index)=>{
41
44
  if (Array.isArray(componentInfo)) {
@@ -19,5 +19,6 @@ export { useVersion } from './hooks/useVersion.js';
19
19
  export { useWindowSize } from './hooks/useWindowSize.js';
20
20
  export { initPageData, warmPageData } from './initPageData.js';
21
21
  export { NoSSR } from './NoSSR.js';
22
+ export { safePreconnect, safePreload } from './reactDom.js';
22
23
  export { isActive, pathnameToRouteService, preloadLink } from './route.js';
23
24
  export { addLeadingSlash, addTrailingSlash, cleanUrlByConfig, isEqualPath, isProduction, normalizeHrefInRuntime, normalizeImagePath, removeBase, removeTrailingSlash, routePathToMdPath, withBase, withSiteOrigin, } from './utils.js';
@@ -19,5 +19,6 @@ export { useVersion } from "./hooks/useVersion.js";
19
19
  export { useWindowSize } from "./hooks/useWindowSize.js";
20
20
  export { initPageData, warmPageData } from "./initPageData.js";
21
21
  export { NoSSR } from "./NoSSR.js";
22
+ export { safePreconnect, safePreload } from "./reactDom.js";
22
23
  export { isActive, pathnameToRouteService, preloadLink } from "./route.js";
23
24
  export { addLeadingSlash, addTrailingSlash, cleanUrlByConfig, isEqualPath, isProduction, normalizeHrefInRuntime, normalizeImagePath, removeBase, removeTrailingSlash, routePathToMdPath, withBase, withSiteOrigin } from "./utils.js";
@@ -0,0 +1,19 @@
1
+ type CrossOrigin = '' | 'anonymous' | 'use-credentials';
2
+ type Preconnect = (href: string, options?: {
3
+ crossOrigin?: CrossOrigin;
4
+ }) => void;
5
+ type Preload = (href: string, options?: {
6
+ as: 'audio' | 'document' | 'embed' | 'fetch' | 'font' | 'image' | 'object' | 'script' | 'style' | 'track' | 'video' | 'worker';
7
+ crossOrigin?: CrossOrigin;
8
+ fetchPriority?: 'high' | 'low' | 'auto';
9
+ imageSizes?: string;
10
+ imageSrcSet?: string;
11
+ integrity?: string;
12
+ media?: string;
13
+ nonce?: string;
14
+ referrerPolicy?: ReferrerPolicy;
15
+ type?: string;
16
+ }) => void;
17
+ export declare const safePreconnect: Preconnect | undefined;
18
+ export declare const safePreload: Preload | undefined;
19
+ export {};
@@ -0,0 +1,5 @@
1
+ import * as __rspack_external_react_dom_20ef40a6 from "react-dom";
2
+ const reactDOM = __rspack_external_react_dom_20ef40a6;
3
+ const safePreconnect = reactDOM.preconnect ?? reactDOM.default?.preconnect;
4
+ const safePreload = reactDOM.preload ?? reactDOM.default?.preload;
5
+ export { safePreconnect, safePreload };
@@ -68,6 +68,21 @@
68
68
  display: flex;
69
69
  }
70
70
 
71
+ .rp-hover-group__item__icon {
72
+ object-fit: contain;
73
+ flex: 0 0 16px;
74
+ width: 16px;
75
+ height: 16px;
76
+ font-size: 16px;
77
+ line-height: 16px;
78
+ }
79
+
80
+ .rp-hover-group__item__icon > svg, .rp-hover-group__item__icon > img {
81
+ object-fit: contain;
82
+ width: 100%;
83
+ height: 100%;
84
+ }
85
+
71
86
  .rp-hover-group__item--active {
72
87
  color: var(--rp-c-brand);
73
88
  cursor: auto;
@@ -1,6 +1,6 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { matchNavbar, useLocation } from "@rspress/core/runtime";
3
- import { Link, Tag } from "@rspress/core/theme";
3
+ import { Link, SvgWrapper, Tag } from "@rspress/core/theme";
4
4
  import clsx from "clsx";
5
5
  import "./index.css";
6
6
  function HoverGroupItem({ item, activeMatcher, depth = 0 }) {
@@ -24,6 +24,10 @@ function HoverGroupItem({ item, activeMatcher, depth = 0 }) {
24
24
  hrefLang: item.lang,
25
25
  rel: item.rel,
26
26
  children: [
27
+ item.icon && /*#__PURE__*/ jsx(SvgWrapper, {
28
+ icon: item.icon,
29
+ className: "rp-hover-group__item__icon"
30
+ }),
27
31
  item.text,
28
32
  'tag' in item && item.tag && /*#__PURE__*/ jsx(Tag, {
29
33
  tag: item.tag
@@ -60,6 +64,10 @@ function HoverGroupItem({ item, activeMatcher, depth = 0 }) {
60
64
  hrefLang: lang,
61
65
  rel: rel,
62
66
  children: [
67
+ item.icon && /*#__PURE__*/ jsx(SvgWrapper, {
68
+ icon: item.icon,
69
+ className: "rp-hover-group__item__icon"
70
+ }),
63
71
  text,
64
72
  'tag' in item && item.tag && /*#__PURE__*/ jsx(Tag, {
65
73
  tag: item.tag
@@ -69,6 +77,10 @@ function HoverGroupItem({ item, activeMatcher, depth = 0 }) {
69
77
  className: "rp-hover-group__item__link",
70
78
  lang: lang,
71
79
  children: [
80
+ item.icon && /*#__PURE__*/ jsx(SvgWrapper, {
81
+ icon: item.icon,
82
+ className: "rp-hover-group__item__icon"
83
+ }),
72
84
  text,
73
85
  'tag' in item && item.tag && /*#__PURE__*/ jsx(Tag, {
74
86
  tag: item.tag
@@ -86,6 +98,10 @@ function HoverGroupItem({ item, activeMatcher, depth = 0 }) {
86
98
  children: /*#__PURE__*/ jsxs("div", {
87
99
  className: "rp-hover-group__item__link",
88
100
  children: [
101
+ item.icon && /*#__PURE__*/ jsx(SvgWrapper, {
102
+ icon: item.icon,
103
+ className: "rp-hover-group__item__icon"
104
+ }),
89
105
  item.text,
90
106
  'tag' in item && item.tag && /*#__PURE__*/ jsx(Tag, {
91
107
  tag: item.tag
@@ -5,13 +5,13 @@ import { IconCopy, IconSuccess, SvgWrapper, copyToClipboard } from "@rspress/cor
5
5
  import { useCallback, useRef, useState } from "react";
6
6
  import "./index.css";
7
7
  import "./LlmsCopyButton.css";
8
+ import { getLlmsCopyContent } from "./getLlmsCopyContent.js";
8
9
  import { useMdUrl } from "./useMdUrl.js";
9
10
  /**
10
11
  * Inspired from fumadocs docsite
11
12
  * @from https://github.com/fuma-nama/fumadocs/blob/5723bbe58ef805a5421a780abf235a10b251be2f/apps/docs/app/docs/%5B...slug%5D/page.client.tsx#L11
12
13
  * @license MIT
13
- */ const cache = new Map();
14
- function LlmsCopyButton(props) {
14
+ */ function LlmsCopyButton(props) {
15
15
  const { onClick, ...otherProps } = props;
16
16
  const t = useI18n();
17
17
  const { pathname } = useMdUrl();
@@ -22,8 +22,7 @@ function LlmsCopyButton(props) {
22
22
  setLoading(true);
23
23
  const url = pathname;
24
24
  try {
25
- const content = cache.get(url) ?? await fetch(url).then((res)=>res.text());
26
- cache.set(url, content);
25
+ const content = await getLlmsCopyContent(url);
27
26
  const isCopied = await copyToClipboard(content);
28
27
  if (!isCopied) return;
29
28
  setFinished(true);
@@ -2,8 +2,8 @@ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useI18n } from "@rspress/core/runtime";
3
3
  import { IconCopy, IconSuccess, SvgWrapper, copyToClipboard } from "@rspress/core/theme";
4
4
  import { useCallback, useRef, useState } from "react";
5
+ import { getLlmsCopyContent } from "./getLlmsCopyContent.js";
5
6
  import { useMdUrl } from "./useMdUrl.js";
6
- const cache = new Map();
7
7
  function LlmsCopyRow() {
8
8
  const t = useI18n();
9
9
  const { pathname } = useMdUrl();
@@ -14,8 +14,7 @@ function LlmsCopyRow() {
14
14
  if (!pathname) return;
15
15
  setLoading(true);
16
16
  try {
17
- const content = cache.get(pathname) ?? await fetch(pathname).then((res)=>res.text());
18
- cache.set(pathname, content);
17
+ const content = await getLlmsCopyContent(pathname);
19
18
  const isCopied = await copyToClipboard(content);
20
19
  if (!isCopied) return;
21
20
  setFinished(true);
@@ -0,0 +1,2 @@
1
+ import type React from 'react';
2
+ export declare function LlmsHint(): string | React.JSX.Element | null;
@@ -0,0 +1,40 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { routePathToMdPath, usePage, useSite, withBase, withSiteOrigin } from "@rspress/core/runtime";
3
+ const visuallyHiddenStyle = {
4
+ position: 'absolute',
5
+ width: 1,
6
+ height: 1,
7
+ padding: 0,
8
+ margin: -1,
9
+ overflow: 'hidden',
10
+ clip: 'rect(0, 0, 0, 0)',
11
+ clipPath: 'inset(50%)',
12
+ whiteSpace: 'nowrap',
13
+ border: 0
14
+ };
15
+ function createLlmsHintText({ llmsTxtUrl, llmsFullTxtUrl, pageMdUrl }) {
16
+ return `For AI agents: the complete documentation index is available at ${llmsTxtUrl}, the full documentation bundle is available at ${llmsFullTxtUrl}, and this page is available as Markdown at ${pageMdUrl}.`;
17
+ }
18
+ function LlmsHint() {
19
+ const { page } = usePage();
20
+ const { site } = useSite();
21
+ if (!page?.routePath) return null;
22
+ const isMultiVersion = site.multiVersion.versions.length > 0;
23
+ const versionPrefix = isMultiVersion && page.version !== site.multiVersion.default ? `${page.version}/` : '';
24
+ const langPrefix = page.lang === site.lang ? '' : `${page.lang}/`;
25
+ const llmsTxtUrl = withSiteOrigin(withBase(`/${versionPrefix}${langPrefix}llms.txt`));
26
+ const llmsFullTxtUrl = withSiteOrigin(withBase(`/${versionPrefix}${langPrefix}llms-full.txt`));
27
+ const pageMdUrl = withSiteOrigin(routePathToMdPath(page.routePath));
28
+ const hintText = createLlmsHintText({
29
+ llmsTxtUrl,
30
+ llmsFullTxtUrl,
31
+ pageMdUrl
32
+ });
33
+ if (import.meta.env.SSG_MD) return `> ${hintText}\n\n`;
34
+ return /*#__PURE__*/ jsx("div", {
35
+ className: "rp-llms-hint",
36
+ style: visuallyHiddenStyle,
37
+ children: hintText
38
+ });
39
+ }
40
+ export { LlmsHint };
@@ -0,0 +1 @@
1
+ export declare function getLlmsCopyContent(url: string): Promise<string>;
@@ -0,0 +1,14 @@
1
+ const cache = new Map();
2
+ const DEV_COPY_WARNING = 'Warning: Markdown content is unavailable in development mode; run `rspress build` to use this feature.';
3
+ async function getLlmsCopyContent(url) {
4
+ if (import.meta.env.DEV) {
5
+ console.warn(DEV_COPY_WARNING);
6
+ return DEV_COPY_WARNING;
7
+ }
8
+ const cachedContent = cache.get(url);
9
+ if (void 0 !== cachedContent) return cachedContent;
10
+ const content = await fetch(url).then((response)=>response.text());
11
+ cache.set(url, content);
12
+ return content;
13
+ }
14
+ export { getLlmsCopyContent };
@@ -1,5 +1,5 @@
1
1
  export { LlmsContainer, type LlmsContainerProps } from './LlmsContainer.js';
2
2
  export { LlmsCopyButton, type LlmsCopyButtonProps } from './LlmsCopyButton.js';
3
- export { LlmsHiddenHint } from './LlmsHiddenHint.js';
3
+ export { LlmsHint } from './LlmsHint.js';
4
4
  export { LlmsViewOptions, type LlmsViewOptionsItem, type LlmsViewOptionsProps, } from './LlmsViewOptions.js';
5
5
  export { useMdUrl } from './useMdUrl.js';
@@ -1,5 +1,5 @@
1
1
  export { LlmsContainer } from "./LlmsContainer.js";
2
2
  export { LlmsCopyButton } from "./LlmsCopyButton.js";
3
- export { LlmsHiddenHint } from "./LlmsHiddenHint.js";
3
+ export { LlmsHint } from "./LlmsHint.js";
4
4
  export { LlmsViewOptions } from "./LlmsViewOptions.js";
5
5
  export { useMdUrl } from "./useMdUrl.js";
@@ -48,6 +48,21 @@
48
48
  display: flex;
49
49
  }
50
50
 
51
+ .rp-nav-menu__item__leading-icon {
52
+ object-fit: contain;
53
+ flex: 0 0 16px;
54
+ width: 16px;
55
+ height: 16px;
56
+ font-size: 16px;
57
+ line-height: 16px;
58
+ }
59
+
60
+ .rp-nav-menu__item__leading-icon > svg, .rp-nav-menu__item__leading-icon > img {
61
+ object-fit: contain;
62
+ width: 100%;
63
+ height: 100%;
64
+ }
65
+
51
66
  .rp-nav-menu__item:hover .rp-nav-menu__item__container {
52
67
  color: var(--rp-c-brand);
53
68
  text-align: center;
@@ -19,6 +19,10 @@ function NavMenuItemInner({ menuItem, children }) {
19
19
  lang: menuItem.lang,
20
20
  rel: menuItem.rel,
21
21
  children: [
22
+ menuItem.icon && /*#__PURE__*/ jsx(SvgWrapper, {
23
+ icon: menuItem.icon,
24
+ className: "rp-nav-menu__item__leading-icon"
25
+ }),
22
26
  menuItem.text,
23
27
  menuItem.tag && /*#__PURE__*/ jsx(Tag, {
24
28
  tag: menuItem.tag
@@ -28,6 +32,10 @@ function NavMenuItemInner({ menuItem, children }) {
28
32
  }) : /*#__PURE__*/ jsxs("div", {
29
33
  className: "rp-nav-menu__item__container",
30
34
  children: [
35
+ menuItem.icon && /*#__PURE__*/ jsx(SvgWrapper, {
36
+ icon: menuItem.icon,
37
+ className: "rp-nav-menu__item__leading-icon"
38
+ }),
31
39
  menuItem.text,
32
40
  menuItem.tag && /*#__PURE__*/ jsx(Tag, {
33
41
  tag: menuItem.tag
@@ -35,12 +35,27 @@
35
35
  line-height: 22px;
36
36
  }
37
37
 
38
- .rp-nav-screen-menu-item__icon {
38
+ .rp-nav-screen-menu-item__arrow {
39
39
  transition: transform .25s ease-in;
40
40
  transform: rotate(-90deg);
41
41
  }
42
42
 
43
- .rp-nav-screen-menu-item--open .rp-nav-screen-menu-item__icon {
43
+ .rp-nav-screen-menu-item__icon {
44
+ object-fit: contain;
45
+ flex: 0 0 16px;
46
+ width: 16px;
47
+ height: 16px;
48
+ font-size: 16px;
49
+ line-height: 16px;
50
+ }
51
+
52
+ .rp-nav-screen-menu-item__icon > svg, .rp-nav-screen-menu-item__icon > img {
53
+ object-fit: contain;
54
+ width: 100%;
55
+ height: 100%;
56
+ }
57
+
58
+ .rp-nav-screen-menu-item--open .rp-nav-screen-menu-item__arrow {
44
59
  transform: rotate(0);
45
60
  }
46
61
 
@@ -8,6 +8,20 @@ const SvgDown = (props)=>/*#__PURE__*/ jsx(SvgWrapper, {
8
8
  icon: IconArrowDown,
9
9
  ...props
10
10
  });
11
+ function NavScreenMenuItemContent({ menuItem }) {
12
+ return /*#__PURE__*/ jsxs(Fragment, {
13
+ children: [
14
+ menuItem.icon && /*#__PURE__*/ jsx(SvgWrapper, {
15
+ icon: menuItem.icon,
16
+ className: "rp-nav-screen-menu-item__icon"
17
+ }),
18
+ menuItem.text,
19
+ menuItem.tag && /*#__PURE__*/ jsx(Tag, {
20
+ tag: menuItem.tag
21
+ })
22
+ ]
23
+ });
24
+ }
11
25
  function NavScreenMenuItemRaw({ left, right, isOpen, isActive, onClick, href, download }) {
12
26
  if (href) return /*#__PURE__*/ jsxs(Link, {
13
27
  href: href,
@@ -47,13 +61,8 @@ function NavScreenMenuItemWithLink({ menuItem }) {
47
61
  pathname
48
62
  ]);
49
63
  return /*#__PURE__*/ jsx(NavScreenMenuItemRaw, {
50
- left: /*#__PURE__*/ jsxs(Fragment, {
51
- children: [
52
- menuItem.text,
53
- menuItem.tag && /*#__PURE__*/ jsx(Tag, {
54
- tag: menuItem.tag
55
- })
56
- ]
64
+ left: /*#__PURE__*/ jsx(NavScreenMenuItemContent, {
65
+ menuItem: menuItem
57
66
  }),
58
67
  right: null,
59
68
  href: menuItem.link,
@@ -66,16 +75,11 @@ function NavScreenMenuItemWithChildren({ menuItem }) {
66
75
  return /*#__PURE__*/ jsxs(Fragment, {
67
76
  children: [
68
77
  /*#__PURE__*/ jsx(NavScreenMenuItemRaw, {
69
- left: /*#__PURE__*/ jsxs(Fragment, {
70
- children: [
71
- menuItem.text,
72
- menuItem.tag && /*#__PURE__*/ jsx(Tag, {
73
- tag: menuItem.tag
74
- })
75
- ]
78
+ left: /*#__PURE__*/ jsx(NavScreenMenuItemContent, {
79
+ menuItem: menuItem
76
80
  }),
77
81
  right: /*#__PURE__*/ jsx(SvgDown, {
78
- className: "rp-nav-screen-menu-item__icon"
82
+ className: "rp-nav-screen-menu-item__arrow"
79
83
  }),
80
84
  isOpen: isOpen,
81
85
  onClick: ()=>setIsOpen(!isOpen),
@@ -107,13 +111,8 @@ function NavScreenMenuItem({ menuItem }) {
107
111
  menuItem: menuItem
108
112
  });
109
113
  return /*#__PURE__*/ jsx(NavScreenMenuItemRaw, {
110
- left: /*#__PURE__*/ jsxs(Fragment, {
111
- children: [
112
- menuItem.text,
113
- menuItem.tag && /*#__PURE__*/ jsx(Tag, {
114
- tag: menuItem.tag
115
- })
116
- ]
114
+ left: /*#__PURE__*/ jsx(NavScreenMenuItemContent, {
115
+ menuItem: menuItem
117
116
  }),
118
117
  right: null
119
118
  });
@@ -40,3 +40,7 @@
40
40
  margin: 1rem 0;
41
41
  }
42
42
 
43
+ .rp-nav-screen-divider:last-child {
44
+ display: none;
45
+ }
46
+
@@ -39,6 +39,10 @@
39
39
  margin-bottom: 16px;
40
40
  }
41
41
 
42
+ .rp-outline__divider:has( + .rp-outline__bottom:empty) {
43
+ display: none;
44
+ }
45
+
42
46
  .rp-outline__toc {
43
47
  padding: 4px var(--rp-outline-padding-x);
44
48
  scrollbar-width: none;
@@ -42,6 +42,7 @@ function SidebarGroup(props) {
42
42
  /*#__PURE__*/ jsx(SidebarItemRaw, {
43
43
  active: Boolean(active),
44
44
  link: item.link,
45
+ icon: item.icon,
45
46
  tag: item.tag,
46
47
  text: item.text,
47
48
  context: item.context,
@@ -83,7 +84,9 @@ function SidebarGroup(props) {
83
84
  depth: depth + 1,
84
85
  dividerType: item.dividerType
85
86
  }, index) : isSidebarSectionHeader(item) ? /*#__PURE__*/ jsx(SidebarSectionHeader, {
86
- sectionHeaderText: item.sectionHeaderText
87
+ icon: item.icon,
88
+ sectionHeaderText: item.sectionHeaderText,
89
+ tag: item.tag
87
90
  }, index) : /*#__PURE__*/ jsx(SidebarItem, {
88
91
  item: item,
89
92
  depth: depth + 1,
@@ -70,6 +70,21 @@
70
70
  display: flex;
71
71
  }
72
72
 
73
+ .rp-sidebar-item__icon {
74
+ object-fit: contain;
75
+ flex: 0 0 16px;
76
+ width: 16px;
77
+ height: 16px;
78
+ font-size: 16px;
79
+ line-height: 16px;
80
+ }
81
+
82
+ .rp-sidebar-item__icon > svg, .rp-sidebar-item__icon > img {
83
+ object-fit: contain;
84
+ width: 100%;
85
+ height: 100%;
86
+ }
87
+
73
88
  .rp-sidebar-item__right {
74
89
  align-items: center;
75
90
  display: flex;