@rspress/core 2.0.3 → 2.0.5

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 (119) hide show
  1. package/dist/{0~7675.872de9ba.js → 0~7675.423f6a06.js} +2 -2
  2. package/dist/{5485.888e77db.js → 5485.0bb24594.js} +1 -1
  3. package/dist/cli/index.js +1 -1
  4. package/dist/config/loadConfigFile.js +1 -1
  5. package/dist/eject-theme/components/Badge/index.tsx +1 -1
  6. package/dist/eject-theme/components/Button/index.tsx +1 -1
  7. package/dist/eject-theme/components/CodeBlock/index.scss +5 -1
  8. package/dist/eject-theme/components/DocContent/docComponents/title.tsx +7 -2
  9. package/dist/eject-theme/components/EditLink/index.scss +10 -8
  10. package/dist/eject-theme/components/EditLink/index.tsx +13 -4
  11. package/dist/eject-theme/components/HoverGroup/index.tsx +8 -2
  12. package/dist/eject-theme/components/Llms/LlmsCopyRow.tsx +51 -0
  13. package/dist/eject-theme/components/Llms/LlmsOpenRow.scss +10 -0
  14. package/dist/eject-theme/components/Llms/LlmsOpenRow.tsx +170 -0
  15. package/dist/eject-theme/components/Nav/NavMenu.tsx +7 -1
  16. package/dist/eject-theme/components/Nav/hooks.tsx +2 -0
  17. package/dist/eject-theme/components/NavScreen/NavScreenLangs.tsx +8 -1
  18. package/dist/eject-theme/components/NavScreen/NavScreenMenuItem.scss +0 -1
  19. package/dist/eject-theme/components/Outline/ScrollToTop.tsx +12 -34
  20. package/dist/eject-theme/components/Outline/index.scss +41 -5
  21. package/dist/eject-theme/components/Outline/index.tsx +19 -2
  22. package/dist/eject-theme/components/PackageManagerTabs/index.tsx +10 -2
  23. package/dist/eject-theme/components/Search/SearchPanel.tsx +2 -1
  24. package/dist/eject-theme/components/Search/logic/providers/LocalProvider.ts +1 -1
  25. package/dist/eject-theme/components/Sidebar/SidebarItem.scss +0 -2
  26. package/dist/eject-theme/components/SourceCode/index.tsx +1 -1
  27. package/dist/eject-theme/components/SvgWrapper/index.tsx +5 -2
  28. package/dist/eject-theme/components/Tabs/index.scss +1 -1
  29. package/dist/eject-theme/components/Tabs/index.tsx +1 -1
  30. package/dist/index.js +1 -1
  31. package/dist/node/auto-nav-sidebar/index.js +1 -1
  32. package/dist/node/auto-nav-sidebar/normalize.js +30 -4
  33. package/dist/node/constants.js +1 -1
  34. package/dist/node/initRsbuild.js +11 -9
  35. package/dist/node/last-updated/index.js +1 -1
  36. package/dist/node/logger/hint.d.ts +0 -3
  37. package/dist/node/logger/hint.js +7 -1
  38. package/dist/node/mdx/{loader.15e0b2d2.js → loader.15134034.js} +2 -0
  39. package/dist/node/mdx/options.js +4 -2
  40. package/dist/node/mdx/rehypePlugins/headerAnchor.js +1 -1
  41. package/dist/node/mdx/rehypePlugins/shiki.js +1 -1
  42. package/dist/node/mdx/rehypePlugins/transformers/add-line-numbers.js +3 -2
  43. package/dist/node/mdx/rehypePlugins/transformers/add-wrap-code.js +4 -3
  44. package/dist/node/route/RoutePage.js +1 -1
  45. package/dist/node/route/RouteService.js +1 -1
  46. package/dist/node/route/extractPageData.js +23 -2
  47. package/dist/node/route/normalizeRoutePath.js +1 -1
  48. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.d.ts +4 -4
  49. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.js +4 -4
  50. package/dist/node/runtimeModule/i18n.js +1 -1
  51. package/dist/node/runtimeModule/pageData/createPageData.js +2 -2
  52. package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
  53. package/dist/node/serve.js +1 -1
  54. package/dist/node/ssg/renderPage.js +1 -1
  55. package/dist/node/ssg/renderPageWorker.js +1 -1
  56. package/dist/node/ssg/renderPages.js +2 -2
  57. package/dist/node/ssg-md/llms/emitLlmsTxt.js +1 -1
  58. package/dist/node/ssg-md/llms/llmsTxt.js +5 -2
  59. package/dist/node/ssg-md/remarkSplitMdx.js +12 -2
  60. package/dist/node/ssg-md/renderPage.js +1 -1
  61. package/dist/node/ssg-md/renderPages.js +1 -1
  62. package/dist/node/utils/createHash.js +1 -1
  63. package/dist/node/utils/flattenMdxContent.js +1 -1
  64. package/dist/node/utils/reactAlias.d.ts +1 -0
  65. package/dist/node/utils/reactAlias.js +34 -2
  66. package/dist/runtime/ssrMdServerEntry.js +1 -1
  67. package/dist/theme/assets/copy.js +3 -3
  68. package/dist/theme/assets/edit.js +18 -0
  69. package/dist/theme/assets/scroll-to-top.js +36 -0
  70. package/dist/theme/assets/success.js +3 -2
  71. package/dist/theme/components/Badge/index.d.ts +1 -2
  72. package/dist/theme/components/Button/index.d.ts +1 -2
  73. package/dist/theme/components/CodeBlock/index.css +5 -1
  74. package/dist/theme/components/DocContent/docComponents/title.js +5 -2
  75. package/dist/theme/components/EditLink/index.css +2 -2
  76. package/dist/theme/components/EditLink/index.d.ts +3 -1
  77. package/dist/theme/components/EditLink/index.js +18 -4
  78. package/dist/theme/components/HoverGroup/index.js +8 -1
  79. package/dist/theme/components/Llms/LlmsCopyRow.d.ts +1 -0
  80. package/dist/theme/components/Llms/LlmsCopyRow.js +50 -0
  81. package/dist/theme/components/Llms/LlmsOpenRow.css +11 -0
  82. package/dist/theme/components/Llms/LlmsOpenRow.d.ts +3 -0
  83. package/dist/theme/components/Llms/LlmsOpenRow.js +168 -0
  84. package/dist/theme/components/Nav/NavMenu.js +3 -0
  85. package/dist/theme/components/Nav/hooks.d.ts +2 -0
  86. package/dist/theme/components/Nav/hooks.js +3 -1
  87. package/dist/theme/components/NavScreen/NavScreenLangs.js +3 -0
  88. package/dist/theme/components/NavScreen/NavScreenMenuItem.css +0 -1
  89. package/dist/theme/components/Outline/ScrollToTop.d.ts +1 -2
  90. package/dist/theme/components/Outline/ScrollToTop.js +7 -32
  91. package/dist/theme/components/Outline/index.css +39 -4
  92. package/dist/theme/components/Outline/index.js +16 -4
  93. package/dist/theme/components/PackageManagerTabs/index.js +10 -3
  94. package/dist/theme/components/Search/SearchPanel.js +1 -1
  95. package/dist/theme/components/Search/logic/providers/LocalProvider.js +1 -1
  96. package/dist/theme/components/Sidebar/SidebarItem.css +0 -2
  97. package/dist/theme/components/SourceCode/index.d.ts +1 -2
  98. package/dist/theme/components/SvgWrapper/index.d.ts +1 -2
  99. package/dist/theme/components/SvgWrapper/index.js +2 -1
  100. package/dist/theme/components/Tabs/index.css +1 -1
  101. package/dist/theme/components/Tabs/index.d.ts +1 -1
  102. package/dist/theme/icons.d.ts +2 -0
  103. package/dist/theme/icons.js +5 -1
  104. package/dist/theme/index.d.ts +8 -5
  105. package/dist/theme/index.js +4 -1
  106. package/dist/theme/layout/DocLayout/index.css +3 -3
  107. package/dist/theme/styles/base.css +4 -0
  108. package/nav-json-schema.json +12 -0
  109. package/package.json +16 -16
  110. package/dist/_private/react/index.js +0 -2
  111. package/dist/_private/react/reconciler.js +0 -169
  112. package/dist/_private/react/render.js +0 -168
  113. package/dist/eject-theme/components/Outline/ScrollToTop.scss +0 -13
  114. package/dist/node/ssg-md/react/index.d.ts +0 -1
  115. package/dist/node/ssg-md/react/reconciler.d.ts +0 -18
  116. package/dist/node/ssg-md/react/render.d.ts +0 -2
  117. package/dist/node/ssg-md/react/render.test.d.ts +0 -1
  118. package/dist/theme/components/Outline/ScrollToTop.css +0 -14
  119. /package/dist/{8995.421b464f.js → 7744.421b464f.js} +0 -0
@@ -44,6 +44,10 @@ export type PackageManagerTabProps = (
44
44
  // contains `--npm` or `--jsr` (in which case explicit npm behavior is desired).
45
45
  const transformDenoPositional = (cmd: string) => {
46
46
  const parts = cmd.split(' ');
47
+ const subcommand = parts[1];
48
+ const isRun = subcommand === 'run';
49
+ let transformedFirst = false;
50
+
47
51
  const transformed = parts.map((tok, idx) => {
48
52
  // only transform positional args (after "deno" and the subcommand)
49
53
  if (
@@ -52,6 +56,10 @@ const transformDenoPositional = (cmd: string) => {
52
56
  !tok.includes(':') &&
53
57
  !/^https?:/.test(tok)
54
58
  ) {
59
+ if (isRun && transformedFirst) {
60
+ return tok;
61
+ }
62
+ transformedFirst = true;
55
63
  return `npm:${tok}`;
56
64
  }
57
65
  return tok;
@@ -164,7 +172,7 @@ export function PackageManagerTabs({
164
172
  case 'bun':
165
173
  return 'bunx';
166
174
  case 'deno':
167
- return 'deno run';
175
+ return 'deno run -A';
168
176
  default:
169
177
  return packageManager;
170
178
  }
@@ -180,7 +188,7 @@ export function PackageManagerTabs({
180
188
  case 'bun':
181
189
  return 'bun';
182
190
  case 'deno':
183
- return 'deno run';
191
+ return 'deno run -A';
184
192
  default:
185
193
  return packageManager;
186
194
  }
@@ -116,7 +116,8 @@ export function SearchPanel({ focused, setFocused }: SearchPanelProps) {
116
116
  const t = useI18n();
117
117
  const navigate = useLinkNavigate();
118
118
  const { search, title: siteTitle } = siteData;
119
- const versionedSearch = typeof search !== 'boolean' && search?.versioned;
119
+ const versionedSearch =
120
+ typeof search !== 'boolean' && (search?.versioned ?? true);
120
121
  const DEFAULT_RESULT = [
121
122
  { group: siteTitle, result: [], renderType: RenderType.Default },
122
123
  ];
@@ -104,7 +104,7 @@ export class LocalProvider implements Provider {
104
104
  }
105
105
 
106
106
  const { currentLang, currentVersion } = options;
107
- const versioned = options.versioned;
107
+ const versioned = options.versioned ?? true;
108
108
 
109
109
  this.#fetchPromise = this.#getPages(
110
110
  currentLang,
@@ -36,8 +36,6 @@
36
36
  font-weight: 400;
37
37
  display: inline-block;
38
38
  font-size: 1em;
39
- transform: translate(0, -0.2em);
40
- transition: transform 0.2s ease;
41
39
  margin-left: 0.2em;
42
40
  margin-right: 0.1em;
43
41
  }
@@ -2,7 +2,7 @@ import { useI18n } from '@rspress/core/runtime';
2
2
  import { IconGithub, IconGitlab, SvgWrapper } from '@theme';
3
3
  import './index.scss';
4
4
 
5
- interface SourceCodeProps {
5
+ export interface SourceCodeProps {
6
6
  href: string;
7
7
  platform?: 'github' | 'gitlab';
8
8
  }
@@ -1,3 +1,4 @@
1
+ import { normalizeImagePath } from '@rspress/core/runtime';
1
2
  import { renderHtmlOrText } from '@theme';
2
3
 
3
4
  /**
@@ -14,7 +15,7 @@ function isUrlOrPath(str: string): boolean {
14
15
  );
15
16
  }
16
17
 
17
- type SvgWrapperProps = {
18
+ export type SvgWrapperProps = {
18
19
  icon: string | React.FC<React.SVGProps<SVGSVGElement>>;
19
20
  } & React.SVGProps<SVGSVGElement>;
20
21
 
@@ -44,7 +45,9 @@ export function SvgWrapper({ icon: Icon, ...rest }: SvgWrapperProps) {
44
45
  }
45
46
  // URL or file path
46
47
  if (isUrlOrPath(Icon)) {
47
- return <img className={className} src={Icon} alt="" />;
48
+ return (
49
+ <img className={className} src={normalizeImagePath(Icon)} alt="" />
50
+ );
48
51
  }
49
52
  // Fallback: emoji/text/HTML
50
53
  return <span className={className} {...renderHtmlOrText(Icon)} />;
@@ -54,7 +54,7 @@
54
54
  background-color 0.2s ease-out;
55
55
  cursor: pointer;
56
56
 
57
- border-radius: var(--rp-radius-small);
57
+ border-radius: calc(1.5 * var(--rp-radius-small));
58
58
 
59
59
  &:last-child {
60
60
  margin-right: 0;
@@ -18,7 +18,7 @@ type TabItem = {
18
18
  content?: ReactNode;
19
19
  };
20
20
 
21
- interface TabsProps {
21
+ export interface TabsProps {
22
22
  values?: ReactNode[] | ReadonlyArray<ReactNode> | TabItem[];
23
23
  /**
24
24
  * @default 0
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ export { build } from "./node/build.js";
5
5
  export { defineConfig } from "./config/defineConfig.js";
6
6
  export { dev } from "./node/dev.js";
7
7
  export { logger } from "./6289.29817fb4.js";
8
- export { matchPath } from "./8995.421b464f.js";
8
+ export { matchPath } from "./7744.421b464f.js";
9
9
  export { remarkFileCodeBlock } from "./node/mdx/remarkPlugins/fileCodeBlock.js";
10
10
  export { remarkLink } from "./node/mdx/remarkPlugins/link.js";
11
11
  export { serve } from "./node/serve.js";
@@ -1,5 +1,5 @@
1
1
  import { node_path } from "../../6289.29817fb4.js";
2
- import { DEFAULT_PAGE_EXTENSIONS } from "../../8995.421b464f.js";
2
+ import { DEFAULT_PAGE_EXTENSIONS } from "../../7744.421b464f.js";
3
3
  import { processLocales, combineWalkResult } from "./locales.js";
4
4
  import { walk } from "./walk.js";
5
5
  async function runAutoNavSide(config, metaFileSet, mdFileSet) {
@@ -4,6 +4,7 @@ import { createError } from "../utils/error.js";
4
4
  import { PUBLIC_DIR } from "../constants.js";
5
5
  import { pathExists, extractInfoFromFrontmatterWithAbsolutePath, readJson } from "./utils.js";
6
6
  import { absolutePathToRoutePath, addRoutePrefix } from "../route/RoutePage.js";
7
+ import { RouteService } from "../route/RouteService.js";
7
8
  const AUTO_NAV_SIDEBAR_ERROR_PREFIX = '[auto-nav-sidebar] ';
8
9
  function getFileKey(realPath, docsDir) {
9
10
  return realPath ? slash(relative(docsDir, realPath).replace(extname(realPath), '')) : '';
@@ -11,7 +12,12 @@ function getFileKey(realPath, docsDir) {
11
12
  async function fsDirToMetaItems(workDir, docsDir, extensions) {
12
13
  let subItems;
13
14
  try {
14
- subItems = await readdir(workDir);
15
+ subItems = (await readdir(workDir)).sort((a, b)=>{
16
+ const aIsIndex = 'index' === a.replace(/\.[^/.]+$/, '');
17
+ const bIsIndex = 'index' === b.replace(/\.[^/.]+$/, '');
18
+ if (aIsIndex !== bIsIndex) return aIsIndex ? -1 : 1;
19
+ return a.localeCompare(b);
20
+ });
15
21
  } catch (e) {
16
22
  const metaFilePath = join(workDir, '_meta.json');
17
23
  throw createError(`${AUTO_NAV_SIDEBAR_ERROR_PREFIX}Failed to read directory: ${picocolors.yellow(workDir)}, maybe it does not exist. Please check it in ${picocolors.cyan(metaFilePath)}. (${e})`);
@@ -42,8 +48,16 @@ async function metaItemToSidebarItem(metaItem, workDir, docsDir, extensions, met
42
48
  if ('string' == typeof metaItem) return metaFileItemToSidebarItem(metaItem, workDir, docsDir, extensions, mdFileSet);
43
49
  const { type } = metaItem;
44
50
  if ('file' === type) return metaFileItemToSidebarItem(metaItem, workDir, docsDir, extensions, mdFileSet);
45
- if ('dir' === type) return metaDirItemToSidebarItem(metaItem, workDir, docsDir, extensions, metaFileSet, mdFileSet, false);
46
- if ('dir-section-header' === type) return metaDirSectionHeaderItemToSidebarItem(metaItem, workDir, docsDir, extensions, metaFileSet, mdFileSet);
51
+ if ('dir' === type) {
52
+ const group = await metaDirItemToSidebarItem(metaItem, workDir, docsDir, extensions, metaFileSet, mdFileSet, false);
53
+ if (0 === group.items.length && !group.link) return null;
54
+ return group;
55
+ }
56
+ if ('dir-section-header' === type) {
57
+ const items = await metaDirSectionHeaderItemToSidebarItem(metaItem, workDir, docsDir, extensions, metaFileSet, mdFileSet);
58
+ if (items.length <= 1) return null;
59
+ return items;
60
+ }
47
61
  if ('custom-link' === type) return metaCustomLinkItemToSidebarItem(metaItem, workDir, docsDir);
48
62
  if ('divider' === type) return metaDividerToSidebarItem(metaItem);
49
63
  if ('section-header' === type) return metaSectionHeaderToSidebarItem(metaItem);
@@ -75,6 +89,8 @@ async function metaFileItemToSidebarItem(metaItemRaw, workDir, docsDir, extensio
75
89
  throw createError(`${AUTO_NAV_SIDEBAR_ERROR_PREFIX}${picocolors.white('Missing page file:')} ${picocolors.yellow(`"${absolutePath}"`)}\n${picocolors.white('Please check')} ${picocolors.cyan(join(workDir, '_meta.json'))}.`);
76
90
  }
77
91
  const link = absolutePathToRoutePath(absolutePathWithExt, docsDir);
92
+ const routeService = RouteService.getInstance();
93
+ if (routeService?.isExistRoute && !routeService.isExistRoute(link)) return null;
78
94
  const info = await extractInfoFromFrontmatterWithAbsolutePath(absolutePathWithExt, docsDir);
79
95
  const title = label || info.title;
80
96
  mdFileSet.add(absolutePathWithExt);
@@ -107,10 +123,11 @@ async function metaDirItemToSidebarItem(metaItem, workDir, docsDir, extensions,
107
123
  }
108
124
  return 'index.md' !== name && 'index.mdx' !== i && 'index' !== i;
109
125
  }) : dirMetaJson).map((item)=>metaItemToSidebarItem(item, dirAbsolutePath, docsDir, extensions, metaFileSet, mdFileSet)));
110
- return items.flat();
126
+ return items.flat().filter(Boolean);
111
127
  }
112
128
  try {
113
129
  const sameNameFile = await metaFileItemToSidebarItem(name, workDir, docsDir, extensions, mdFileSet);
130
+ if (!sameNameFile) throw new Error(`Excluded route: ${name}`);
114
131
  const { link, text, _fileKey, context, overviewHeaders, tag } = sameNameFile;
115
132
  return {
116
133
  text: label || text || name,
@@ -141,6 +158,15 @@ async function metaDirItemToSidebarItem(metaItem, workDir, docsDir, extensions,
141
158
  };
142
159
  {
143
160
  const indexFile = await metaFileItemToSidebarItem('index', dirAbsolutePath, docsDir, extensions, mdFileSet);
161
+ if (!indexFile) return {
162
+ text: label || name,
163
+ collapsible,
164
+ collapsed,
165
+ items: await getItems(),
166
+ overviewHeaders: metaJsonOverviewHeaders,
167
+ context: metaJsonContext,
168
+ _fileKey: getFileKey(dirAbsolutePath, docsDir)
169
+ };
144
170
  const { link, text, _fileKey, context, overviewHeaders, tag } = indexFile;
145
171
  return {
146
172
  text: label || text || name,
@@ -1,4 +1,4 @@
1
- import { createRequire, package_namespaceObject } from "../5485.888e77db.js";
1
+ import { createRequire, package_namespaceObject } from "../5485.0bb24594.js";
2
2
  import { node_path } from "../6289.29817fb4.js";
3
3
  const constants_require = createRequire(import.meta.url);
4
4
  const RSPRESS_VERSION = package_namespaceObject.rE;
@@ -1,11 +1,11 @@
1
- import { createRequire, fileURLToPath, package_namespaceObject } from "../5485.888e77db.js";
1
+ import { createRequire, fileURLToPath, package_namespaceObject } from "../5485.0bb24594.js";
2
2
  import { node_path } from "../6289.29817fb4.js";
3
- import { removeTrailingSlash, MDX_OR_MD_REGEXP, cwd } from "../9348.1beb3e25.js";
4
- import { PLUGIN_REACT_NAME, pluginReact, pluginVirtualModule } from "../8995.421b464f.js";
3
+ import { addTrailingSlash, removeTrailingSlash, cwd, MDX_OR_MD_REGEXP } from "../9348.1beb3e25.js";
4
+ import { PLUGIN_REACT_NAME, pluginReact, pluginVirtualModule } from "../7744.421b464f.js";
5
5
  import { createError } from "./utils/error.js";
6
6
  import { PUBLIC_DIR, CSR_CLIENT_ENTRY, SSR_CLIENT_ENTRY, OUTPUT_DIR, SSG_MD_SERVER_ENTRY, inlineThemeScript, NODE_SSG_BUNDLE_FOLDER, isProduction, PACKAGE_ROOT, SSR_SERVER_ENTRY, TEMPLATE_PATH, NODE_SSG_MD_BUNDLE_FOLDER, DEFAULT_THEME, NODE_SSG_MD_BUNDLE_NAME, DEFAULT_TITLE, NODE_SSG_BUNDLE_NAME } from "./constants.js";
7
7
  import { hintBuilderPluginsBreakingChange, hintThemeBreakingChange } from "./logger/hint.js";
8
- import { resolveReactRouterDomAlias, resolveReactAlias } from "./utils/reactAlias.js";
8
+ import { resolveReactRouterDomAlias, resolveReactRenderToMarkdownAlias, resolveReactAlias } from "./utils/reactAlias.js";
9
9
  import { rsbuildPluginDocVM } from "./runtimeModule/pageData/rsbuildPlugin.js";
10
10
  import { socialLinksVMPlugin } from "./runtimeModule/socialLinks.js";
11
11
  import { i18nVMPlugin } from "./runtimeModule/i18n.js";
@@ -33,8 +33,8 @@ async function getVirtualModulesFromPlugins(pluginDriver) {
33
33
  async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeService, pluginDriver) {
34
34
  const CUSTOM_THEME_DIR = node_path.isAbsolute(config.themeDir) ? config.themeDir : node_path.join(cwd(), config.themeDir);
35
35
  const outDir = config?.outDir ?? OUTPUT_DIR;
36
- const base = config?.base ?? '';
37
- const assetPrefix = isProduction() ? removeTrailingSlash(config?.builderConfig?.output?.assetPrefix ?? base) : '';
36
+ const base = config?.base ?? '/';
37
+ const assetPrefix = isProduction() ? addTrailingSlash(config?.builderConfig?.output?.assetPrefix ?? base) : '/';
38
38
  const normalizeIcon = (icon)=>{
39
39
  if (!icon) return;
40
40
  icon = icon.toString();
@@ -43,10 +43,11 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
43
43
  return icon;
44
44
  };
45
45
  await hintThemeBreakingChange(CUSTOM_THEME_DIR);
46
- const [reactCSRAlias, reactSSRAlias, reactRouterDomAlias] = await Promise.all([
46
+ const [reactCSRAlias, reactSSRAlias, reactRouterDomAlias, reactRenderToMarkdownAlias] = await Promise.all([
47
47
  resolveReactAlias(false),
48
48
  enableSSG ? resolveReactAlias(true) : Promise.resolve({}),
49
- resolveReactRouterDomAlias()
49
+ resolveReactRouterDomAlias(),
50
+ enableSSG && config.llms ? resolveReactRenderToMarkdownAlias() : Promise.resolve({})
50
51
  ]);
51
52
  const context = {
52
53
  userDocRoot,
@@ -307,7 +308,8 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
307
308
  resolve: {
308
309
  alias: {
309
310
  ...reactSSRAlias,
310
- ...reactRouterDomAlias
311
+ ...reactRouterDomAlias,
312
+ ...reactRenderToMarkdownAlias
311
313
  }
312
314
  },
313
315
  tools: {
@@ -1,4 +1,4 @@
1
- import { execa } from "../../0~7675.872de9ba.js";
1
+ import { execa } from "../../0~7675.423f6a06.js";
2
2
  function transform(timestamp, lang) {
3
3
  return new Date(timestamp).toLocaleString(lang || 'zh');
4
4
  }
@@ -6,9 +6,6 @@ import type { NavJson } from '../auto-nav-sidebar/type.js';
6
6
  */
7
7
  export declare function hintThemeBreakingChange(customThemeDir: string): Promise<void>;
8
8
  export declare function hintBuilderPluginsBreakingChange(config: UserConfig): void;
9
- /**
10
- * Possible reasons for printing "ssg: false" and some troubleshooting guidelines for users.
11
- */
12
9
  export declare function hintSSGFailed(): void;
13
10
  /**
14
11
  * Print "ssg: false" explicitly to give users a clear perception.
@@ -56,7 +56,10 @@ ${picocolors.greenBright(` builderConfig: {
56
56
  process.exit(1);
57
57
  }
58
58
  }
59
+ let isSSGFailedLogged = false;
59
60
  function hintSSGFailed() {
61
+ if (isSSGFailedLogged) return;
62
+ isSSGFailedLogged = true;
60
63
  logger.info("[Rspress v2] `ssg: true` requires the source code to support SSR. If the code is not compatible to SSR, the build process will fail. You can try:\n 1. Fix code to make it SSR-compatible.\n 2. Set `ssg: false` if the code in node_modules may be difficult to fix, but the SSG feature will be lost.");
61
64
  }
62
65
  function hintSSGFalse() {
@@ -66,7 +69,10 @@ function hintReactVersion() {
66
69
  logger.info('[Rspress v2] Rspress support React 18 and 19, please confirm that both react and react-dom are installed in package.json with the same version. ');
67
70
  }
68
71
  function hintNavJsonChangeThenPanic(metaJson, metaJsonDir, docsDir) {
69
- if (metaJson.some((i)=>'object' == typeof i && ('activeMatch' in i || 'text' in i || 'link' in i || 'items' in i || 'icon' in i || 'ariaLabel' in i || 'target' in i))) {
72
+ if (metaJson.some((i)=>{
73
+ if ('object' == typeof i && 'type' in i && 'custom-link' === i.type) return false;
74
+ return 'object' == typeof i && ('activeMatch' in i || 'text' in i);
75
+ })) {
70
76
  const error = new Error('[Rspress v2] Detected that you are still using top level `_meta.json` to configure the nav, but it has been changed to `_nav.json` in Rspress v2. Please rename the top level `_meta.json` to `_nav.json` accordingly.');
71
77
  logger.error(error);
72
78
  const dir = relative(docsDir, metaJsonDir);
@@ -1,6 +1,8 @@
1
1
  export { default as rehype } from "@shikijs/rehype";
2
2
  export { default as rehype_external_links } from "rehype-external-links";
3
3
  export { default as rehype_raw } from "rehype-raw";
4
+ export { default as remark_cjk_friendly } from "remark-cjk-friendly";
5
+ export { default as remark_cjk_friendly_gfm_strikethrough } from "remark-cjk-friendly-gfm-strikethrough";
4
6
  export { default as remark_mdx } from "remark-mdx";
5
7
  export { headingRank } from "hast-util-heading-rank";
6
8
  export { transformerAddLang, transformerAddLineNumbers, transformerAddTitle, transformerAddWrapCode } from "@rspress/core/shiki-transformers";
@@ -1,6 +1,6 @@
1
1
  import { node_path } from "../../6289.29817fb4.js";
2
2
  import { remark_gfm, nodeTypes } from "../../9348.1beb3e25.js";
3
- import { rehype, rehype_external_links, rehype_raw } from "./loader.15e0b2d2.js";
3
+ import { rehype_external_links, rehype_raw, remark_cjk_friendly, rehype, remark_cjk_friendly_gfm_strikethrough } from "./loader.15134034.js";
4
4
  import { remarkToc } from "./remarkPlugins/toc.js";
5
5
  import { remarkContainerSyntax } from "./remarkPlugins/containerSyntax.js";
6
6
  import { remarkFileCodeBlock } from "./remarkPlugins/fileCodeBlock.js";
@@ -15,7 +15,7 @@ async function createMDXOptions(options) {
15
15
  const { docDirectory, config, routeService, filepath, pluginDriver, addDependency, isSsgMd = false } = options;
16
16
  const remarkLinkOptions = config?.markdown?.link;
17
17
  const format = node_path.extname(filepath).slice(1);
18
- const { remarkPlugins: remarkPluginsFromConfig = [], rehypePlugins: rehypePluginsFromConfig = [], globalComponents: globalComponentsFromConfig = [], showLineNumbers = false, defaultWrapCode = false, shiki } = config?.markdown || {};
18
+ const { remarkPlugins: remarkPluginsFromConfig = [], rehypePlugins: rehypePluginsFromConfig = [], globalComponents: globalComponentsFromConfig = [], showLineNumbers = false, defaultWrapCode = false, shiki, cjkFriendlyEmphasis = true } = config?.markdown || {};
19
19
  const rspressPlugins = pluginDriver?.getPlugins() ?? [];
20
20
  const remarkPluginsFromPlugins = rspressPlugins.flatMap((plugin)=>plugin.markdown?.remarkPlugins || []);
21
21
  const rehypePluginsFromPlugins = rspressPlugins.flatMap((plugin)=>plugin.markdown?.rehypePlugins || []);
@@ -28,6 +28,8 @@ async function createMDXOptions(options) {
28
28
  format,
29
29
  remarkPlugins: [
30
30
  remark_gfm,
31
+ cjkFriendlyEmphasis && remark_cjk_friendly,
32
+ cjkFriendlyEmphasis && remark_cjk_friendly_gfm_strikethrough,
31
33
  remarkToc,
32
34
  !isSsgMd && remarkContainerSyntax,
33
35
  [
@@ -1,5 +1,5 @@
1
1
  import { visit, github_slugger, extractTextAndId } from "../../../9348.1beb3e25.js";
2
- import { headingRank } from "../loader.15e0b2d2.js";
2
+ import { headingRank } from "../loader.15134034.js";
3
3
  const rehypeHeaderAnchor = ()=>{
4
4
  const slugger = new github_slugger();
5
5
  return (tree)=>{
@@ -1,4 +1,4 @@
1
- import { transformerAddLang, transformerAddLineNumbers, transformerAddTitle, createCssVariablesTheme, transformerAddWrapCode } from "../loader.15e0b2d2.js";
1
+ import { transformerAddLang, transformerAddLineNumbers, transformerAddTitle, createCssVariablesTheme, transformerAddWrapCode } from "../loader.15134034.js";
2
2
  const cssVariablesTheme = createCssVariablesTheme({
3
3
  name: 'css-variables',
4
4
  variablePrefix: '--shiki-',
@@ -2,7 +2,8 @@ const SHIKI_TRANSFORMER_ADD_LINE_NUMBERS = 'shiki-transformer:add-line-numbers';
2
2
  function hasLineNumbersInMeta(meta) {
3
3
  if (!meta) return;
4
4
  const kvList = meta.split(' ').filter(Boolean);
5
- return kvList.includes('lineNumbers');
5
+ if (kvList.includes('lineNumbers=false')) return false;
6
+ if (kvList.includes('lineNumbers') || kvList.includes('lineNumbers=true')) return true;
6
7
  }
7
8
  function transformerAddLineNumbers(options = {}) {
8
9
  const { defaultShowLineNumbers = false } = options;
@@ -11,7 +12,7 @@ function transformerAddLineNumbers(options = {}) {
11
12
  pre (pre) {
12
13
  const metaHasLineNumbers = hasLineNumbersInMeta(this.options.meta?.__raw);
13
14
  const shouldShowLineNumbers = metaHasLineNumbers ?? defaultShowLineNumbers;
14
- if (shouldShowLineNumbers) pre.properties = {
15
+ if (void 0 !== metaHasLineNumbers || shouldShowLineNumbers) pre.properties = {
15
16
  ...pre.properties,
16
17
  lineNumbers: shouldShowLineNumbers
17
18
  };
@@ -2,7 +2,8 @@ const SHIKI_TRANSFORMER_ADD_WRAP_CODE = 'shiki-transformer:wrap-code';
2
2
  function hasWrapCodeInMeta(meta) {
3
3
  if (!meta) return;
4
4
  const kvList = meta.split(' ').filter(Boolean);
5
- return kvList.includes('wrapCode');
5
+ if (kvList.includes('wrapCode=false')) return false;
6
+ if (kvList.includes('wrapCode') || kvList.includes('wrapCode=true')) return true;
6
7
  }
7
8
  function transformerAddWrapCode(options = {}) {
8
9
  const { defaultWrapCode = false } = options;
@@ -11,9 +12,9 @@ function transformerAddWrapCode(options = {}) {
11
12
  pre (pre) {
12
13
  const metaHasWrapCode = hasWrapCodeInMeta(this.options.meta?.__raw);
13
14
  const shouldWrapCode = metaHasWrapCode ?? defaultWrapCode;
14
- if (shouldWrapCode) pre.properties = {
15
+ if (void 0 !== metaHasWrapCode || shouldWrapCode) pre.properties = {
15
16
  ...pre.properties,
16
- wrapCode: true
17
+ wrapCode: shouldWrapCode
17
18
  };
18
19
  return pre;
19
20
  }
@@ -53,7 +53,7 @@ function absolutePathToRoutePath(absolutePath, docsDir, routeService = RouteServ
53
53
  return absolutePathToRouteMeta(absolutePath, docsDir, routeService).routePath;
54
54
  }
55
55
  function absolutePathToRoutePrefix(absolutePath, docsDir) {
56
- const relativePath = slash(node_path.relative(docsDir, absolutePath.replace(node_path.extname(absolutePath), '')));
56
+ const relativePath = slash(node_path.relative(docsDir, absolutePath));
57
57
  const routeService = RouteService.getInstance();
58
58
  const [versionPrefix, langPrefix] = routeService.getRoutePathParts(relativePath);
59
59
  return `${versionPrefix ? `/${versionPrefix}` : ''}${langPrefix ? `/${langPrefix}` : ''}`;
@@ -1,6 +1,6 @@
1
1
  import { node_path, promises } from "../../6289.29817fb4.js";
2
2
  import { RSPRESS_TEMP_DIR, removeTrailingSlash, addTrailingSlash } from "../../9348.1beb3e25.js";
3
- import { DEFAULT_PAGE_EXTENSIONS, glob } from "../../8995.421b464f.js";
3
+ import { DEFAULT_PAGE_EXTENSIONS, glob } from "../../7744.421b464f.js";
4
4
  import { PUBLIC_DIR } from "../constants.js";
5
5
  import { RoutePage, absolutePathToRoutePath, absolutePathToRelativePath } from "./RoutePage.js";
6
6
  import { createError } from "../utils/error.js";
@@ -1,6 +1,6 @@
1
1
  import { node_path, promises } from "../../6289.29817fb4.js";
2
2
  import { unified, visit, remark_gfm, loadFrontMatter, remark_stringify, MDX_OR_MD_REGEXP } from "../../9348.1beb3e25.js";
3
- import { remove, remark_parse } from "../../8995.421b464f.js";
3
+ import { remove, remark_parse } from "../../7744.421b464f.js";
4
4
  import { applyReplaceRules } from "../utils/applyReplaceRules.js";
5
5
  import { flattenMdxContent } from "../utils/flattenMdxContent.js";
6
6
  import { importStatementRegex } from "../constants.js";
@@ -43,6 +43,26 @@ const SKIP_NODE_TYPES = new Set([
43
43
  'image',
44
44
  'table'
45
45
  ]);
46
+ const CONTAINER_DIRECTIVE_REGEX = /^\s*:::\s*(\w+)\s*(.*)?/;
47
+ const CONTAINER_DIRECTIVE_END_REGEX = /^\s*:::\s*$/;
48
+ function stripContainerDirectives(text) {
49
+ const lines = text.split('\n');
50
+ const result = [];
51
+ let directiveStartIndex = -1;
52
+ for(let i = 0; i < lines.length; i++){
53
+ if (-1 === directiveStartIndex && CONTAINER_DIRECTIVE_REGEX.test(lines[i])) {
54
+ directiveStartIndex = i;
55
+ continue;
56
+ }
57
+ if (-1 !== directiveStartIndex) {
58
+ if (CONTAINER_DIRECTIVE_END_REGEX.test(lines[i])) directiveStartIndex = -1;
59
+ continue;
60
+ }
61
+ result.push(lines[i]);
62
+ }
63
+ if (-1 !== directiveStartIndex) result.push(...lines.slice(directiveStartIndex + 1));
64
+ return result.join('\n');
65
+ }
46
66
  function extractDescription(tree) {
47
67
  const textParts = [];
48
68
  let foundH1 = false;
@@ -59,7 +79,8 @@ function extractDescription(tree) {
59
79
  }
60
80
  }
61
81
  }
62
- return textParts.join(' ');
82
+ const joined = textParts.join('\n');
83
+ return stripContainerDirectives(joined).split('\n').map((l)=>l.trim()).filter(Boolean).join(' ');
63
84
  }
64
85
  async function getPageIndexInfoByRoute(route, options) {
65
86
  const { alias, replaceRules, root, searchCodeBlocks, extractDescription: extractDescriptionConfig = true, searchEnabled = true } = options;
@@ -1,5 +1,5 @@
1
1
  import { addTrailingSlash, addLeadingSlash } from "../../9348.1beb3e25.js";
2
- import { DEFAULT_PAGE_EXTENSIONS } from "../../8995.421b464f.js";
2
+ import { DEFAULT_PAGE_EXTENSIONS } from "../../7744.421b464f.js";
3
3
  const getRoutePathParts = (relativePath, lang, version, langs, versions)=>{
4
4
  const [versionPart, langPart, purePath] = splitRoutePathParts(relativePath, lang, version, langs, versions);
5
5
  return [
@@ -140,10 +140,10 @@ export declare const DEFAULT_I18N_TEXT: {
140
140
  readonly ru: "Скопировать ссылку в формате Markdown";
141
141
  };
142
142
  readonly editLinkText: {
143
- readonly en: "📝 Edit this page";
144
- readonly zh: "📝 编辑此页面";
145
- readonly ja: "📝 このページを編集";
146
- readonly ko: "📝 이 페이지 편집";
143
+ readonly en: "Edit this page";
144
+ readonly zh: "编辑此页面";
145
+ readonly ja: "このページを編集";
146
+ readonly ko: "이 페이지 편집";
147
147
  readonly ru: "Отредактировать страницу";
148
148
  };
149
149
  readonly codeButtonGroupCopyButtonText: {
@@ -140,10 +140,10 @@ const DEFAULT_I18N_TEXT = {
140
140
  ru: 'Скопировать ссылку в формате Markdown'
141
141
  },
142
142
  editLinkText: {
143
- en: '📝 Edit this page',
144
- zh: '📝 编辑此页面',
145
- ja: '📝 このページを編集',
146
- ko: '📝 이 페이지 편집',
143
+ en: 'Edit this page',
144
+ zh: '编辑此页面',
145
+ ja: 'このページを編集',
146
+ ko: '이 페이지 편집',
147
147
  ru: 'Отредактировать страницу'
148
148
  },
149
149
  codeButtonGroupCopyButtonText: {
@@ -1,4 +1,4 @@
1
- import { createRequire } from "../../5485.888e77db.js";
1
+ import { createRequire } from "../../5485.0bb24594.js";
2
2
  import { picocolors, join, logger } from "../../6289.29817fb4.js";
3
3
  import { DEFAULT_I18N_TEXT } from "./DEFAULT_I18N_TEXT.js";
4
4
  import { createError } from "../utils/error.js";
@@ -1,5 +1,5 @@
1
1
  import { SEARCH_INDEX_NAME } from "../../../9348.1beb3e25.js";
2
- import { groupBy } from "../../../8995.421b464f.js";
2
+ import { groupBy } from "../../../7744.421b464f.js";
3
3
  import { extractPageData } from "../../route/extractPageData.js";
4
4
  import { createHash } from "../../utils/createHash.js";
5
5
  function deletePrivateField(obj) {
@@ -28,7 +28,7 @@ async function createPageData(context) {
28
28
  searchEnabled
29
29
  });
30
30
  await pluginDriver.modifySearchIndexData(pages);
31
- const versioned = 'boolean' != typeof userConfig.search && userConfig.search?.versioned;
31
+ const versioned = 'boolean' != typeof userConfig.search && (userConfig.search?.versioned ?? true);
32
32
  const groupedPages = groupBy(pages, (page)=>{
33
33
  if (page.frontmatter?.pageType === 'home') return 'noindex';
34
34
  const version = versioned ? page.version : '';
@@ -1,5 +1,5 @@
1
1
  import { logger } from "../../../6289.29817fb4.js";
2
- import { pluginVirtualModule } from "../../../8995.421b464f.js";
2
+ import { pluginVirtualModule } from "../../../7744.421b464f.js";
3
3
  import { createPageData } from "./createPageData.js";
4
4
  const rsbuildPluginDocVM = async ({ config, userDocRoot, routeService, pluginDriver })=>{
5
5
  const ref = {
@@ -1,4 +1,4 @@
1
- import { mergeRsbuildConfig } from "../8995.421b464f.js";
1
+ import { mergeRsbuildConfig } from "../7744.421b464f.js";
2
2
  import { PluginDriver } from "./PluginDriver.js";
3
3
  import { initRsbuild } from "./initRsbuild.js";
4
4
  import { RouteService } from "./route/RouteService.js";
@@ -1,4 +1,4 @@
1
- import { transformHtmlTemplate, pathToFileURL, createHead } from "../../5485.888e77db.js";
1
+ import { transformHtmlTemplate, pathToFileURL, createHead } from "../../5485.0bb24594.js";
2
2
  import { logger, picocolors } from "../../6289.29817fb4.js";
3
3
  import { hintSSGFailed } from "../logger/hint.js";
4
4
  import { renderHtmlTemplate } from "./renderHtmlTemplate.js";
@@ -1,6 +1,6 @@
1
1
  import { workerData } from "./renderPageWorker.165b5d46.js";
2
2
  import { createError } from "../utils/error.js";
3
- import { pMap } from "../../5485.888e77db.js";
3
+ import { pMap } from "../../5485.0bb24594.js";
4
4
  import { renderPage } from "./renderPage.js";
5
5
  const params = workerData?.[1]?.params;
6
6
  if (!params) throw createError('SSG Worker Thread workerData params missing');
@@ -1,8 +1,8 @@
1
1
  /*! For license information please see renderPages.js.LICENSE.txt */
2
2
  import { logger, picocolors } from "../../6289.29817fb4.js";
3
- import { chunk } from "../../8995.421b464f.js";
3
+ import { chunk } from "../../7744.421b464f.js";
4
4
  import { SSGWorkerThreadTaskSize, getNumberOfThreads, SSGWorkerThreadRecyclerMaxMemory, SSGConcurrency } from "./ssgEnv.js";
5
- import { pMap } from "../../5485.888e77db.js";
5
+ import { pMap } from "../../5485.0bb24594.js";
6
6
  import { renderPage } from "./renderPage.js";
7
7
  import { hintSSGFailed } from "../logger/hint.js";
8
8
  import { renderHtmlTemplate } from "./renderHtmlTemplate.js";
@@ -1,5 +1,5 @@
1
1
  import { getSidebarDataGroup } from "../../../9348.1beb3e25.js";
2
- import { matchPath } from "../../../8995.421b464f.js";
2
+ import { matchPath } from "../../../7744.421b464f.js";
3
3
  import { generateLlmsTxt, generateLlmsFullTxt } from "./llmsTxt.js";
4
4
  async function emitLlmsTxt(config, routeService, emitAsset, mdContents) {
5
5
  const base = config.base ?? '/';
@@ -1,4 +1,5 @@
1
1
  import { normalizeHref, withBase } from "../../../9348.1beb3e25.js";
2
+ import { logger } from "../../../6289.29817fb4.js";
2
3
  import { extractInfoFromFrontmatterWithAbsolutePath } from "../../auto-nav-sidebar/utils.js";
3
4
  function routePathToMdPath(routePath, base) {
4
5
  let url = routePath;
@@ -8,7 +9,8 @@ function routePathToMdPath(routePath, base) {
8
9
  }
9
10
  async function generateLlmsTxt(routeGroups, others, navList, title, description, base, routeService) {
10
11
  const lines = [];
11
- const summary = `# ${title}${description ? `\n\n> ${description}` : ''}`;
12
+ if (!title) logger.warn('No `title` is configured in your Rspress setup. Please set `title` in rspress.config.ts so llms.txt can include an appropriate heading.');
13
+ const summary = title ? `# ${title}${description ? `\n\n> ${description}` : ''}` : '';
12
14
  async function genH2Part(nav, routes) {
13
15
  const lines = [];
14
16
  const { text } = nav;
@@ -47,7 +49,8 @@ async function generateLlmsTxt(routeGroups, others, navList, title, description,
47
49
  text: 'Others'
48
50
  }, others);
49
51
  lines.push(...otherLines);
50
- const llmsTxt = `${summary}\n${lines.join('\n')}`;
52
+ let llmsTxt;
53
+ llmsTxt = summary ? lines.length > 0 ? `${summary}\n${lines.join('\n')}` : summary : lines.join('\n').trimStart();
51
54
  return llmsTxt;
52
55
  }
53
56
  function generateLlmsFullTxt(routeGroups, navList, others, base, mdContents) {