@rspress/core 2.0.2 → 2.0.4

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 (122) hide show
  1. package/dist/{0~7675.6e0caa9f.js → 0~7675.423f6a06.js} +2 -2
  2. package/dist/{5485.5f8db93a.js → 5485.7e481fde.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/OverviewGroup/index.scss +5 -11
  23. package/dist/eject-theme/components/PackageManagerTabs/index.tsx +10 -2
  24. package/dist/eject-theme/components/Search/SearchPanel.tsx +2 -1
  25. package/dist/eject-theme/components/Search/logic/providers/LocalProvider.ts +1 -1
  26. package/dist/eject-theme/components/Sidebar/SidebarItem.scss +0 -2
  27. package/dist/eject-theme/components/SidebarMenu/index.scss +25 -1
  28. package/dist/eject-theme/components/SidebarMenu/index.tsx +5 -2
  29. package/dist/eject-theme/components/SourceCode/index.tsx +1 -1
  30. package/dist/eject-theme/components/SvgWrapper/index.tsx +5 -2
  31. package/dist/eject-theme/components/Tabs/index.scss +1 -1
  32. package/dist/eject-theme/components/Tabs/index.tsx +1 -1
  33. package/dist/eject-theme/components/Tag/index.tsx +2 -0
  34. package/dist/index.js +1 -1
  35. package/dist/node/auto-nav-sidebar/index.js +1 -1
  36. package/dist/node/auto-nav-sidebar/normalize.js +30 -4
  37. package/dist/node/constants.js +1 -1
  38. package/dist/node/initRsbuild.js +11 -9
  39. package/dist/node/last-updated/index.js +1 -1
  40. package/dist/node/logger/hint.d.ts +0 -3
  41. package/dist/node/logger/hint.js +8 -4
  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/RouteService.js +1 -1
  45. package/dist/node/route/extractPageData.js +23 -2
  46. package/dist/node/route/normalizeRoutePath.js +1 -1
  47. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.d.ts +4 -4
  48. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.js +4 -4
  49. package/dist/node/runtimeModule/i18n.js +1 -1
  50. package/dist/node/runtimeModule/pageData/createPageData.js +2 -2
  51. package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
  52. package/dist/node/serve.js +1 -1
  53. package/dist/node/ssg/renderPage.js +1 -1
  54. package/dist/node/ssg/renderPageWorker.js +1 -1
  55. package/dist/node/ssg/renderPages.js +2 -2
  56. package/dist/node/ssg-md/llms/emitLlmsTxt.js +1 -1
  57. package/dist/node/ssg-md/remarkSplitMdx.js +11 -1
  58. package/dist/node/ssg-md/renderPage.js +4 -3
  59. package/dist/node/ssg-md/renderPages.js +1 -1
  60. package/dist/node/utils/createHash.js +1 -1
  61. package/dist/node/utils/flattenMdxContent.js +1 -1
  62. package/dist/node/utils/reactAlias.d.ts +1 -0
  63. package/dist/node/utils/reactAlias.js +34 -2
  64. package/dist/runtime/ssrMdServerEntry.js +1 -1
  65. package/dist/theme/assets/copy.js +3 -3
  66. package/dist/theme/assets/edit.js +18 -0
  67. package/dist/theme/assets/scroll-to-top.js +36 -0
  68. package/dist/theme/assets/success.js +3 -2
  69. package/dist/theme/components/Badge/index.d.ts +1 -2
  70. package/dist/theme/components/Button/index.d.ts +1 -2
  71. package/dist/theme/components/CodeBlock/index.css +5 -1
  72. package/dist/theme/components/DocContent/docComponents/title.js +5 -2
  73. package/dist/theme/components/EditLink/index.css +2 -2
  74. package/dist/theme/components/EditLink/index.d.ts +3 -1
  75. package/dist/theme/components/EditLink/index.js +18 -4
  76. package/dist/theme/components/HoverGroup/index.js +8 -1
  77. package/dist/theme/components/Llms/LlmsCopyRow.d.ts +1 -0
  78. package/dist/theme/components/Llms/LlmsCopyRow.js +50 -0
  79. package/dist/theme/components/Llms/LlmsOpenRow.css +11 -0
  80. package/dist/theme/components/Llms/LlmsOpenRow.d.ts +3 -0
  81. package/dist/theme/components/Llms/LlmsOpenRow.js +168 -0
  82. package/dist/theme/components/Nav/NavMenu.js +3 -0
  83. package/dist/theme/components/Nav/hooks.d.ts +2 -0
  84. package/dist/theme/components/Nav/hooks.js +3 -1
  85. package/dist/theme/components/NavScreen/NavScreenLangs.js +3 -0
  86. package/dist/theme/components/NavScreen/NavScreenMenuItem.css +0 -1
  87. package/dist/theme/components/Outline/ScrollToTop.d.ts +1 -2
  88. package/dist/theme/components/Outline/ScrollToTop.js +7 -32
  89. package/dist/theme/components/Outline/index.css +39 -4
  90. package/dist/theme/components/Outline/index.js +16 -4
  91. package/dist/theme/components/OverviewGroup/index.css +2 -9
  92. package/dist/theme/components/PackageManagerTabs/index.js +10 -3
  93. package/dist/theme/components/Search/SearchPanel.js +1 -1
  94. package/dist/theme/components/Search/logic/providers/LocalProvider.js +1 -1
  95. package/dist/theme/components/Sidebar/SidebarItem.css +0 -2
  96. package/dist/theme/components/SidebarMenu/index.css +25 -1
  97. package/dist/theme/components/SidebarMenu/index.js +3 -1
  98. package/dist/theme/components/SourceCode/index.d.ts +1 -2
  99. package/dist/theme/components/SvgWrapper/index.d.ts +1 -2
  100. package/dist/theme/components/SvgWrapper/index.js +2 -1
  101. package/dist/theme/components/Tabs/index.css +1 -1
  102. package/dist/theme/components/Tabs/index.d.ts +1 -1
  103. package/dist/theme/components/Tag/index.js +4 -0
  104. package/dist/theme/icons.d.ts +2 -0
  105. package/dist/theme/icons.js +5 -1
  106. package/dist/theme/index.d.ts +8 -5
  107. package/dist/theme/index.js +4 -1
  108. package/dist/theme/layout/DocLayout/index.css +3 -3
  109. package/dist/theme/layout/Layout/index.js +10 -4
  110. package/dist/theme/styles/base.css +4 -0
  111. package/nav-json-schema.json +12 -0
  112. package/package.json +14 -16
  113. package/dist/_private/react/index.js +0 -2
  114. package/dist/_private/react/reconciler.js +0 -169
  115. package/dist/_private/react/render.js +0 -118
  116. package/dist/eject-theme/components/Outline/ScrollToTop.scss +0 -13
  117. package/dist/node/ssg-md/react/index.d.ts +0 -1
  118. package/dist/node/ssg-md/react/reconciler.d.ts +0 -18
  119. package/dist/node/ssg-md/react/render.d.ts +0 -1
  120. package/dist/node/ssg-md/react/render.test.d.ts +0 -1
  121. package/dist/theme/components/Outline/ScrollToTop.css +0 -14
  122. /package/dist/{2577.421b464f.js → 7744.421b464f.js} +0 -0
@@ -95,16 +95,10 @@
95
95
  &__item {
96
96
  width: 200px;
97
97
  flex: 0 0 200px;
98
- min-width: 25%; // 4 columns
99
- max-width: 25%; // 4 columns
98
+ min-width: 33.33%; // 3 columns
99
+ max-width: 33.33%; // 3 columns
100
100
  word-break: break-all;
101
101
 
102
- @media (min-width: 769px) and (max-width: 1280px) {
103
- // 3 columns
104
- min-width: 33%;
105
- max-width: 33%;
106
- }
107
-
108
102
  @media (max-width: 768px) {
109
103
  // 2 columns or 1 columns
110
104
  min-width: 50%;
@@ -135,16 +129,16 @@
135
129
  // Grid layout for items without content (no headers/items)
136
130
  &__grid {
137
131
  display: grid;
138
- grid-template-columns: repeat(4, 1fr);
132
+ grid-template-columns: repeat(4, 1fr); // 4 columns by default
139
133
  gap: 20px;
140
134
  width: 100%;
141
135
 
142
136
  @media (max-width: 1280px) {
143
- grid-template-columns: repeat(3, 1fr);
137
+ grid-template-columns: repeat(3, 1fr); // 3 columns for medium screens
144
138
  }
145
139
 
146
140
  @media (max-width: 768px) {
147
- grid-template-columns: repeat(2, 1fr);
141
+ grid-template-columns: repeat(2, 1fr); // 2 columns for small screens
148
142
  }
149
143
 
150
144
  @media (max-width: 480px) {
@@ -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
  }
@@ -15,13 +15,37 @@
15
15
  font-style: normal;
16
16
  font-weight: 600;
17
17
 
18
- &__left,
18
+ &__left {
19
+ display: flex;
20
+ gap: 8px;
21
+ align-items: center;
22
+ height: 100%;
23
+ background: transparent;
24
+ flex-shrink: 0;
25
+ }
26
+
19
27
  &__right {
20
28
  display: flex;
21
29
  gap: 8px;
22
30
  align-items: center;
23
31
  height: 100%;
24
32
  background: transparent;
33
+ min-width: 0;
34
+ overflow: hidden;
35
+
36
+ &__text {
37
+ overflow: hidden;
38
+ display: -webkit-box;
39
+ line-clamp: 2;
40
+ -webkit-line-clamp: 2;
41
+ -webkit-box-orient: vertical;
42
+ text-overflow: ellipsis;
43
+ }
44
+
45
+ &__icon,
46
+ .rp-progress-circle {
47
+ flex-shrink: 0;
48
+ }
25
49
  }
26
50
 
27
51
  @media (min-width: 1280px) {
@@ -104,17 +104,20 @@ export const SidebarMenu = forwardRef(
104
104
  >
105
105
  {scrolledHeader?.text ? (
106
106
  <span
107
- className="rp-doc"
107
+ className="rp-sidebar-menu__right__text rp-doc"
108
108
  {...renderInlineMarkdown(scrolledHeader.text)}
109
109
  />
110
110
  ) : (
111
- <span>{t('outlineTitle')}</span>
111
+ <span className="rp-sidebar-menu__right__text">
112
+ {t('outlineTitle')}
113
+ </span>
112
114
  )}
113
115
  <ReadPercent size={14} strokeWidth={2} />
114
116
  {/* TODO: discussion */}
115
117
  {headers.length !== 0 && (
116
118
  <SvgWrapper
117
119
  icon={IconArrowRight}
120
+ className="rp-sidebar-menu__right__icon"
118
121
  style={{
119
122
  transform: isOutlineOpen ? 'rotate(90deg)' : 'rotate(0deg)',
120
123
  transition: 'transform 0.2s ease-out',
@@ -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
@@ -91,6 +91,8 @@ export const Tag = ({ tag }: { tag?: string }) => {
91
91
  <span>deprecated</span>
92
92
  </Badge>
93
93
  );
94
+ } else if (normalizedTag === 'new') {
95
+ return <Badge text="new" type="tip" />;
94
96
  }
95
97
 
96
98
  if (BADGE_TAGS[normalizedTag as keyof typeof BADGE_TAGS]) {
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 "./2577.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 "../../2577.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.5f8db93a.js";
1
+ import { createRequire, package_namespaceObject } from "../5485.7e481fde.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.5f8db93a.js";
1
+ import { createRequire, fileURLToPath, package_namespaceObject } from "../5485.7e481fde.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 "../2577.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.6e0caa9f.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,10 +56,11 @@ ${picocolors.greenBright(` builderConfig: {
56
56
  process.exit(1);
57
57
  }
58
58
  }
59
+ let isSSGFailedLogged = false;
59
60
  function hintSSGFailed() {
60
- 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:
61
- 1. Fix code to make it SSR-compatible.
62
- 2. Set \`ssg: false\` if the code in node_modules may be difficult to fix, but the SSG feature will be lost.`);
61
+ if (isSSGFailedLogged) return;
62
+ isSSGFailedLogged = true;
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.");
63
64
  }
64
65
  function hintSSGFalse() {
65
66
  logger.info('`ssg: false` detected, SSG will be disabled.');
@@ -68,7 +69,10 @@ function hintReactVersion() {
68
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. ');
69
70
  }
70
71
  function hintNavJsonChangeThenPanic(metaJson, metaJsonDir, docsDir) {
71
- 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
+ })) {
72
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.');
73
77
  logger.error(error);
74
78
  const dir = relative(docsDir, metaJsonDir);
@@ -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
  }
@@ -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 "../../2577.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 "../../2577.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 "../../2577.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.5f8db93a.js";
1
+ import { createRequire } from "../../5485.7e481fde.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 "../../../2577.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 "../../../2577.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 "../2577.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.5f8db93a.js";
1
+ import { transformHtmlTemplate, pathToFileURL, createHead } from "../../5485.7e481fde.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.5f8db93a.js";
3
+ import { pMap } from "../../5485.7e481fde.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');