@rspress/core 2.1.2 → 2.1.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 (65) hide show
  1. package/dist/{p~0.js → 8~0.js} +1 -0
  2. package/dist/cli/index.js +1 -1
  3. package/dist/config/loadConfigFile.js +1 -1
  4. package/dist/eject-theme/components/Callout/index.test.tsx +52 -0
  5. package/dist/eject-theme/components/Callout/index.tsx +11 -0
  6. package/dist/eject-theme/components/CodeBlock/index.tsx +1 -1
  7. package/dist/eject-theme/components/HomeHero/index.scss +4 -1
  8. package/dist/eject-theme/components/PageTabs/index.test.tsx +45 -0
  9. package/dist/eject-theme/components/PageTabs/index.tsx +24 -17
  10. package/dist/eject-theme/components/Prompt/index.test.tsx +91 -0
  11. package/dist/eject-theme/components/Prompt/index.tsx +33 -1
  12. package/dist/eject-theme/components/Tabs/index.test.tsx +57 -12
  13. package/dist/eject-theme/components/Tabs/index.tsx +8 -5
  14. package/dist/node/PluginDriver.js +1 -1
  15. package/dist/node/auto-nav-sidebar/index.js +1 -1
  16. package/dist/node/auto-nav-sidebar/locales.js +1 -1
  17. package/dist/node/auto-nav-sidebar/normalize.js +1 -1
  18. package/dist/node/auto-nav-sidebar/utils.js +1 -1
  19. package/dist/node/auto-nav-sidebar/walk.js +1 -1
  20. package/dist/node/eject.js +1 -1
  21. package/dist/node/initRsbuild.js +6 -1
  22. package/dist/node/route/RoutePage.js +1 -1
  23. package/dist/node/route/RouteService.js +1 -1
  24. package/dist/node/route/extractPageData.js +19 -3
  25. package/dist/node/route/normalizeRoutePath.js +1 -1
  26. package/dist/node/route/routeChunkAssets.d.ts +2 -0
  27. package/dist/node/route/routeChunkAssets.js +6 -0
  28. package/dist/node/runtimeModule/i18n/getI18nData.js +1 -1
  29. package/dist/node/runtimeModule/i18n/rsbuildPlugin.js +1 -1
  30. package/dist/node/runtimeModule/pageData/createPageData.js +1 -1
  31. package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
  32. package/dist/node/runtimeModule/searchHooks.js +1 -1
  33. package/dist/node/runtimeModule/siteData/createSiteData.js +1 -1
  34. package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
  35. package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +1 -1
  36. package/dist/node/serve.js +1 -1
  37. package/dist/node/sitemap.js +1 -1
  38. package/dist/node/ssg/alternateLinks.js +1 -1
  39. package/dist/node/ssg/renderHtmlTemplate.js +5 -1
  40. package/dist/node/ssg/renderPageWorker.js +1 -1
  41. package/dist/node/ssg/renderPages.js +1 -1
  42. package/dist/node/ssg/rsbuildPluginSSG.js +1 -1
  43. package/dist/node/ssg/ssgEnv.js +1 -1
  44. package/dist/node/ssg-md/llms/emitLlmsTxt.js +1 -1
  45. package/dist/node/ssg-md/llms/llmsTxt.js +1 -1
  46. package/dist/node/ssg-md/renderPage.js +1 -1
  47. package/dist/node/ssg-md/renderPages.js +1 -1
  48. package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -1
  49. package/dist/node/utils/checkLanguageParity.js +1 -1
  50. package/dist/node/utils/createHash.js +1 -1
  51. package/dist/node/utils/flattenMdxContent.js +1 -1
  52. package/dist/node/utils/getPageKey.js +1 -1
  53. package/dist/node/utils/reactAlias.js +3 -1
  54. package/dist/n~0.js +1 -1
  55. package/dist/theme/components/Callout/index.js +10 -0
  56. package/dist/theme/components/CodeBlock/index.d.ts +1 -1
  57. package/dist/theme/components/HomeHero/index.css +5 -1
  58. package/dist/theme/components/PageTabs/index.js +22 -14
  59. package/dist/theme/components/Prompt/index.js +30 -2
  60. package/dist/theme/components/Tabs/index.js +8 -5
  61. package/dist/theme/hooks/useDynamicToc.js +21 -9
  62. package/dist/theme/logic/useStorageValue.js +1 -0
  63. package/dist/tinypool~0.js +2 -2
  64. package/dist/y~0.js +1 -1
  65. package/package.json +6 -6
@@ -3021,6 +3021,7 @@ export { createHash } from "node:crypto";
3021
3021
  export { chunk, groupBy } from "@rspress/shared/lodash-es";
3022
3022
  export { extractTextAndId, getIconUrlPath, loadFrontMatter } from "@rspress/shared/node-utils";
3023
3023
  export { default as remark_gfm } from "remark-gfm";
3024
+ export { default as remark_mdx } from "remark-mdx";
3024
3025
  export { default as remark_parse } from "remark-parse";
3025
3026
  export { unified } from "unified";
3026
3027
  export { default as node_fs } from "node:fs";
package/dist/cli/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { logger, cac } from "../p~0.js";
1
+ import { logger, cac } from "../8~0.js";
2
2
  import { package_namespaceObject } from "../y~0.js";
3
3
  import { loadConfigFile, resolveDocRoot } from "../config/loadConfigFile.js";
4
4
  import { dev } from "../node/dev.js";
@@ -1,4 +1,4 @@
1
- import { node_path, logger, DEFAULT_CONFIG_NAME, DEFAULT_CONFIG_EXTENSIONS } from "../p~0.js";
1
+ import { node_path, logger, DEFAULT_CONFIG_NAME, DEFAULT_CONFIG_EXTENSIONS } from "../8~0.js";
2
2
  async function loadConfigFile(customConfigFile) {
3
3
  const { loadConfig } = await import("@rsbuild/core");
4
4
  const result = await loadConfig({
@@ -0,0 +1,52 @@
1
+ import { afterEach, describe, expect, it } from '@rstest/core';
2
+ import { renderToMarkdownString } from 'react-render-to-markdown';
3
+ import { Callout } from './index';
4
+
5
+ const originalSsgMd = import.meta.env.SSG_MD;
6
+ afterEach(() => {
7
+ (import.meta.env as unknown as Record<string, unknown>).SSG_MD =
8
+ originalSsgMd;
9
+ });
10
+
11
+ describe('Callout Markdown rendering', () => {
12
+ it('keeps the title and multiple paragraphs inside a quote', async () => {
13
+ (import.meta.env as unknown as Record<string, unknown>).SSG_MD = true;
14
+ const markdown = await renderToMarkdownString(
15
+ <Callout type="warning" title="Before you begin">
16
+ <p>Install dependencies.</p>
17
+ <p>
18
+ Then run <code>pnpm dev</code>.
19
+ </p>
20
+ </Callout>,
21
+ );
22
+ expect(markdown).toMatchInlineSnapshot(`
23
+ "> **Before you begin**
24
+ >
25
+ > Install dependencies.
26
+ >
27
+ > Then run \`pnpm dev\`.
28
+ >
29
+ >
30
+
31
+ "
32
+ `);
33
+ });
34
+
35
+ it('exports all details content with the default title', async () => {
36
+ (import.meta.env as unknown as Record<string, unknown>).SSG_MD = true;
37
+ const markdown = await renderToMarkdownString(
38
+ <Callout type="details">
39
+ <p>Hidden in the browser.</p>
40
+ </Callout>,
41
+ );
42
+ expect(markdown).toMatchInlineSnapshot(`
43
+ "> **Details**
44
+ >
45
+ > Hidden in the browser.
46
+ >
47
+ >
48
+
49
+ "
50
+ `);
51
+ });
52
+ });
@@ -37,6 +37,17 @@ function capitalize(type: string) {
37
37
  * </div>
38
38
  */
39
39
  export function Callout({ type, title, children }: CalloutProps): ReactNode {
40
+ if (import.meta.env.SSG_MD) {
41
+ return (
42
+ <blockquote>
43
+ <p>
44
+ <strong>{title ?? capitalize(type)}</strong>
45
+ </p>
46
+ {children}
47
+ </blockquote>
48
+ );
49
+ }
50
+
40
51
  const isDetails = type === 'details';
41
52
 
42
53
  if (isDetails) {
@@ -30,7 +30,7 @@ export type CodeBlockProps = {
30
30
  containerElementClassName?: string;
31
31
  codeButtonGroupProps?: Omit<
32
32
  CodeButtonGroupProps,
33
- 'preElementRef' | 'wrapCode' | 'toggleWrapCode'
33
+ 'copyElementRef' | 'wrapCode' | 'toggleWrapCode'
34
34
  >;
35
35
  children?: React.ReactNode;
36
36
  };
@@ -19,7 +19,10 @@
19
19
  }
20
20
 
21
21
  @media (max-width: 600px) {
22
- padding: 10px;
22
+ padding: 10px 20px;
23
+ .rp-home-hero__container {
24
+ gap: 18px;
25
+ }
23
26
  .rp-home-hero__title {
24
27
  font-size: 2.5rem;
25
28
  }
@@ -0,0 +1,45 @@
1
+ import { afterEach, expect, it, rs } from '@rstest/core';
2
+ import { renderToMarkdownString } from 'react-render-to-markdown';
3
+ import { PageTab, PageTabs } from './index';
4
+
5
+ rs.mock('@rspress/core/runtime', () => ({
6
+ useSearchParams: () => [new URLSearchParams(), () => {}],
7
+ useLocation: () => ({ search: '' }),
8
+ }));
9
+
10
+ const originalSsgMd = import.meta.env.SSG_MD;
11
+ afterEach(() => {
12
+ (import.meta.env as unknown as Record<string, unknown>).SSG_MD =
13
+ originalSsgMd;
14
+ });
15
+
16
+ it('places each page label next to its content in Markdown', async () => {
17
+ (import.meta.env as unknown as Record<string, unknown>).SSG_MD = true;
18
+ const markdown = await renderToMarkdownString(
19
+ <PageTabs>
20
+ <PageTab
21
+ label={
22
+ <span>
23
+ API <code>v2</code>
24
+ </span>
25
+ }
26
+ >
27
+ <p>API content</p>
28
+ </PageTab>
29
+ <PageTab label="How it works">
30
+ <p>Implementation content</p>
31
+ </PageTab>
32
+ </PageTabs>,
33
+ );
34
+ expect(markdown).toMatchInlineSnapshot(`
35
+ "**API \`v2\`**
36
+
37
+ API content
38
+
39
+ **How it works**
40
+
41
+ Implementation content
42
+
43
+ "
44
+ `);
45
+ });
@@ -1,4 +1,4 @@
1
- import { useSearchParams } from '@rspress/core/runtime';
1
+ import { useLocation, useSearchParams } from '@rspress/core/runtime';
2
2
  import clsx from 'clsx';
3
3
  import {
4
4
  Children,
@@ -52,26 +52,28 @@ export interface PageTabsProps {
52
52
 
53
53
  function usePageTabs(id: string, children: ReactElement<PageTabProps>[]) {
54
54
  const [searchParams, setSearchParams] = useSearchParams();
55
+ const { search } = useLocation();
55
56
 
56
57
  const tabValues = useMemo(() => {
57
58
  return getTabValuesFromChildren(children);
58
59
  }, [children]);
59
60
 
60
61
  function navigateToTab(index: number) {
62
+ const nextSearchParams = new URLSearchParams(searchParams);
61
63
  if (index === 0) {
62
- searchParams.delete(id);
64
+ nextSearchParams.delete(id);
63
65
  } else {
64
- searchParams.set(id, String(index));
66
+ nextSearchParams.set(id, String(index));
65
67
  }
66
- setSearchParams(searchParams);
68
+ setSearchParams(nextSearchParams);
67
69
  }
68
70
 
69
71
  useEffect(() => {
70
- const currIndex = Number(searchParams.get(id) ?? '0');
72
+ const currIndex = Number(new URLSearchParams(search).get(id) ?? '0');
71
73
  if (!Number.isNaN(currIndex)) {
72
74
  document.body.dataset.pageTabsActiveIndex = currIndex.toString();
73
75
  }
74
- }, [searchParams]);
76
+ }, [id, search]);
75
77
 
76
78
  const injectScript = `(function () {
77
79
  var searchParams = new URLSearchParams(window.location.search);
@@ -88,8 +90,6 @@ function usePageTabs(id: string, children: ReactElement<PageTabProps>[]) {
88
90
  };
89
91
  }
90
92
 
91
- let renderCountForTocUpdate = 0;
92
-
93
93
  export const PageTabs = forwardRef(
94
94
  (props: PageTabsProps, ref: ForwardedRef<HTMLDivElement>): ReactElement => {
95
95
  const {
@@ -111,7 +111,22 @@ export const PageTabs = forwardRef(
111
111
  children,
112
112
  );
113
113
 
114
- renderCountForTocUpdate++;
114
+ if (import.meta.env.SSG_MD) {
115
+ return (
116
+ <>
117
+ {tabValues.map(({ label, content }, index) => (
118
+ <div key={index}>
119
+ {label != null && (
120
+ <p>
121
+ <strong>{label}</strong>
122
+ </p>
123
+ )}
124
+ {content}
125
+ </div>
126
+ ))}
127
+ </>
128
+ );
129
+ }
115
130
 
116
131
  return (
117
132
  <>
@@ -159,14 +174,6 @@ export const PageTabs = forwardRef(
159
174
  })}
160
175
  </div>
161
176
  </div>
162
- {/*
163
- Render a hidden <h2> element to trigger a Table of Contents (TOC) update.
164
- This mechanism ensures that the TOC stays in sync with tab content changes,
165
- as some TOC generators rely on heading elements being present in the DOM.
166
- */}
167
- {renderCountForTocUpdate % 2 === 0 ? (
168
- <h2 style={{ display: 'none' }} />
169
- ) : null}
170
177
  </>
171
178
  );
172
179
  },
@@ -0,0 +1,91 @@
1
+ import { afterEach, describe, expect, it, rs } from '@rstest/core';
2
+ import { renderToMarkdownString } from 'react-render-to-markdown';
3
+ import { renderInlineMarkdown } from '../../logic/utils';
4
+ import { Prompt } from './index';
5
+
6
+ rs.mock('@rspress/core/runtime', () => ({
7
+ useI18n: () => (key: string) => key,
8
+ }));
9
+
10
+ rs.mock('@rspress/core/theme', () => ({ renderInlineMarkdown }));
11
+
12
+ const originalSsgMd = import.meta.env.SSG_MD;
13
+
14
+ afterEach(() => {
15
+ if (originalSsgMd === undefined) {
16
+ delete (import.meta.env as unknown as Record<string, unknown>).SSG_MD;
17
+ } else {
18
+ (import.meta.env as unknown as Record<string, unknown>).SSG_MD =
19
+ originalSsgMd;
20
+ }
21
+ });
22
+
23
+ describe('Prompt Markdown rendering', () => {
24
+ it('preserves prompt text in a code block and omits interactive controls', async () => {
25
+ (import.meta.env as unknown as Record<string, unknown>).SSG_MD = true;
26
+ const prompt =
27
+ 'Follow https://rspress.rs/guide/start/getting-started.md.\n\n1. Run `create rspress@latest`.\n2. Start the dev server.\n\n```sh\npnpm dev\n```';
28
+ const markdown = await renderToMarkdownString(
29
+ <Prompt
30
+ title="Start a Rspress project"
31
+ description="Send this to your **AI agent**."
32
+ prompt={prompt}
33
+ />,
34
+ );
35
+ expect(markdown).toMatchInlineSnapshot(`
36
+ "**Start a Rspress project**
37
+
38
+ Send this to your **AI agent**.
39
+
40
+
41
+ \`\`\`\`
42
+ <prompt>
43
+ Follow https://rspress.rs/guide/start/getting-started.md.
44
+
45
+ 1. Run \`create rspress@latest\`.
46
+ 2. Start the dev server.
47
+
48
+ \`\`\`sh
49
+ pnpm dev
50
+ \`\`\`
51
+ </prompt>
52
+ \`\`\`\`
53
+ "
54
+ `);
55
+ expect(markdown).toContain(`<prompt>\n${prompt}\n</prompt>`);
56
+ expect(markdown).toContain('Send this to your **AI agent**.');
57
+ expect(markdown).not.toContain('promptCopyText');
58
+ expect(markdown).not.toContain('For your Agent');
59
+ });
60
+
61
+ it('renders custom children as Markdown without a code block', async () => {
62
+ (import.meta.env as unknown as Record<string, unknown>).SSG_MD = true;
63
+ expect(
64
+ await renderToMarkdownString(
65
+ <Prompt custom eyebrow="Agent resources">
66
+ <h3>Get started</h3>
67
+ <p>
68
+ <a href="https://rspress.rs">Read the guide</a>
69
+ </p>
70
+ </Prompt>,
71
+ ),
72
+ ).toMatchInlineSnapshot(`
73
+ "**Agent resources**
74
+
75
+ ### Get started
76
+
77
+ [Read the guide](https://rspress.rs)
78
+
79
+ "
80
+ `);
81
+ });
82
+
83
+ it('uses the default title and omits absent content', async () => {
84
+ (import.meta.env as unknown as Record<string, unknown>).SSG_MD = true;
85
+ expect(await renderToMarkdownString(<Prompt />)).toMatchInlineSnapshot(`
86
+ "**Agent Prompt**
87
+
88
+ "
89
+ `);
90
+ });
91
+ });
@@ -218,7 +218,8 @@ function CopyablePrompt({
218
218
  <div
219
219
  {...props}
220
220
  ref={cardRef}
221
- className={clsx('rp-prompt', className)}
221
+ // Copyable prompt chrome owns its typography; custom MDX keeps doc styles.
222
+ className={clsx('rp-prompt', 'rp-not-doc', className)}
222
223
  style={
223
224
  {
224
225
  '--rp-prompt-accent': AGENT_ICONS[iconIndex].color,
@@ -329,6 +330,37 @@ function CopyablePrompt({
329
330
  }
330
331
 
331
332
  export function Prompt({ custom = false, ...props }: PromptProps) {
333
+ if (import.meta.env.SSG_MD) {
334
+ const {
335
+ children,
336
+ description,
337
+ eyebrow = 'For your Agent',
338
+ prompt,
339
+ title = 'Agent Prompt',
340
+ } = props;
341
+
342
+ if (custom) {
343
+ return (
344
+ <>
345
+ <p>
346
+ <strong>{eyebrow}</strong>
347
+ </p>
348
+ {children}
349
+ </>
350
+ );
351
+ }
352
+
353
+ return (
354
+ <>
355
+ <p>
356
+ <strong>{title}</strong>
357
+ </p>
358
+ {description ? <p>{description}</p> : null}
359
+ {prompt ? <pre>{`<prompt>\n${prompt}\n</prompt>`}</pre> : null}
360
+ </>
361
+ );
362
+ }
363
+
332
364
  return custom ? <CustomPrompt {...props} /> : <CopyablePrompt {...props} />;
333
365
  }
334
366
 
@@ -1,10 +1,11 @@
1
+ import { setImmediate } from 'node:timers/promises';
1
2
  import { afterEach, describe, expect, it, rs } from '@rstest/core';
3
+ import { Component, type ReactNode } from 'react';
2
4
  import { renderToMarkdownString } from 'react-render-to-markdown';
5
+ import { useStorageValue } from '../../logic/useStorageValue';
3
6
  import { Tab, Tabs } from './index';
4
7
 
5
- rs.mock('@rspress/core/theme', () => ({
6
- useStorageValue: () => ['0', () => {}],
7
- }));
8
+ rs.mock('@rspress/core/theme', () => ({ useStorageValue }));
8
9
 
9
10
  const originalSsgMd = import.meta.env.SSG_MD;
10
11
 
@@ -24,9 +25,27 @@ afterEach(() => {
24
25
  describe('Tabs', () => {
25
26
  it('renders every tab as markdown when SSG_MD is enabled', async () => {
26
27
  setSsgMd(true);
28
+ expect(typeof window).toBe('undefined');
27
29
 
28
- expect(
29
- await renderToMarkdownString(
30
+ const errors: Error[] = [];
31
+ class ErrorBoundary extends Component<{ children: ReactNode }> {
32
+ state = { hasError: false };
33
+
34
+ static getDerivedStateFromError() {
35
+ return { hasError: true };
36
+ }
37
+
38
+ componentDidCatch(error: Error) {
39
+ errors.push(error);
40
+ }
41
+
42
+ render() {
43
+ return this.state.hasError ? null : this.props.children;
44
+ }
45
+ }
46
+
47
+ const markdown = await renderToMarkdownString(
48
+ <ErrorBoundary>
30
49
  <Tabs>
31
50
  <Tab label="npm" value="npm">
32
51
  npm install
@@ -34,18 +53,44 @@ describe('Tabs', () => {
34
53
  <Tab label="pnpm" value="pnpm">
35
54
  pnpm install
36
55
  </Tab>
37
- </Tabs>,
38
- ),
39
- ).toMatchInlineSnapshot(`
40
- "
41
- **npm**
56
+ </Tabs>
57
+ </ErrorBoundary>,
58
+ );
59
+ // Storage subscriptions run after the Markdown renderer resolves its commit.
60
+ await setImmediate();
61
+ expect(errors).toEqual([]);
62
+ expect(markdown).toMatchInlineSnapshot(`
63
+ "**npm**
42
64
 
43
65
  npm install
44
66
 
45
67
  **pnpm**
46
68
 
47
- pnpm install
48
- "
69
+ pnpm install"
70
+ `);
71
+ });
72
+ it('renders React labels and omits missing labels', async () => {
73
+ setSsgMd(true);
74
+ const markdown = await renderToMarkdownString(
75
+ <Tabs>
76
+ <Tab
77
+ label={
78
+ <span>
79
+ GitHub <code>repo</code>
80
+ </span>
81
+ }
82
+ >
83
+ Repository settings
84
+ </Tab>
85
+ <Tab>Unlabelled content</Tab>
86
+ </Tabs>,
87
+ );
88
+ expect(markdown).toMatchInlineSnapshot(`
89
+ "**GitHub \`repo\`**
90
+
91
+ Repository settings
92
+
93
+ Unlabelled content"
49
94
  `);
50
95
  });
51
96
  });
@@ -133,13 +133,16 @@ export const Tabs = forwardRef(
133
133
  if (import.meta.env.SSG_MD) {
134
134
  return (
135
135
  <>
136
- {tabValues.map(({ label, content }) => {
136
+ {tabValues.map(({ label, content }, index) => {
137
137
  return (
138
- <>
139
- {`\n**${label}**\n\n`}
138
+ <div key={index}>
139
+ {label != null && (
140
+ <p>
141
+ <strong>{label}</strong>
142
+ </p>
143
+ )}
140
144
  {content}
141
- {`\n`}
142
- </>
145
+ </div>
143
146
  );
144
147
  })}
145
148
  </>
@@ -1,4 +1,4 @@
1
- import { addTrailingSlash, node_path, addLeadingSlash } from "../p~0.js";
1
+ import { addTrailingSlash, node_path, addLeadingSlash } from "../8~0.js";
2
2
  import { createI18nDataLoader } from "./runtimeModule/i18n/getI18nData.js";
3
3
  import { createError } from "./utils/error.js";
4
4
  import { haveNavSidebarConfig as auto_nav_sidebar_haveNavSidebarConfig } from "./auto-nav-sidebar/index.js";
@@ -1,4 +1,4 @@
1
- import { DEFAULT_PAGE_EXTENSIONS, node_path } from "../../p~0.js";
1
+ import { DEFAULT_PAGE_EXTENSIONS, node_path } from "../../8~0.js";
2
2
  import { processLocales, combineWalkResult } from "./locales.js";
3
3
  import { walk } from "./walk.js";
4
4
  async function runAutoNavSide(config, metaFileSet, mdFileSet) {
@@ -1,4 +1,4 @@
1
- import { node_path } from "../../p~0.js";
1
+ import { node_path } from "../../8~0.js";
2
2
  import { walk } from "./walk.js";
3
3
  function combineWalkResult(walks, versions) {
4
4
  return walks.reduce((acc, cur, curIndex)=>({
@@ -1,6 +1,6 @@
1
1
  import { rspackRequire, compatGetDefaultExport } from "../../rslib-runtime~0.js";
2
2
  import "../../t~0.js";
3
- import { extname, logger, promises_readdir, external_node_path_relative, isExternalUrl, slash, promises_stat, join } from "../../p~0.js";
3
+ import { extname, logger, promises_readdir, external_node_path_relative, isExternalUrl, slash, promises_stat, join } from "../../8~0.js";
4
4
  import { createError } from "../utils/error.js";
5
5
  import { pathExists, extractInfoFromFrontmatterWithAbsolutePath, readJson } from "./utils.js";
6
6
  import { absolutePathToRoutePath, addRoutePrefix } from "../route/RoutePage.js";
@@ -1,4 +1,4 @@
1
- import { node_path, extractTextAndId, promises, loadFrontMatter } from "../../p~0.js";
1
+ import { node_path, extractTextAndId, promises, loadFrontMatter } from "../../8~0.js";
2
2
  import { createError } from "../utils/error.js";
3
3
  async function pathExists(path) {
4
4
  try {
@@ -1,4 +1,4 @@
1
- import { isExternalUrl, node_path, promises } from "../../p~0.js";
1
+ import { isExternalUrl, node_path, promises } from "../../8~0.js";
2
2
  import { pathExists } from "../utils/fs.js";
3
3
  import { readJson } from "./utils.js";
4
4
  import { addRoutePrefix } from "../route/RoutePage.js";
@@ -1,6 +1,6 @@
1
1
  import { rspackRequire, compatGetDefaultExport } from "../rslib-runtime~0.js";
2
2
  import "../t~0.js";
3
- import { node_path, logger, promises } from "../p~0.js";
3
+ import { node_path, logger, promises } from "../8~0.js";
4
4
  import { EJECTED_THEME } from "./constants.js";
5
5
  const picocolors = rspackRequire("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
6
6
  var picocolors_default = /*#__PURE__*/ compatGetDefaultExport(picocolors);
@@ -1,4 +1,4 @@
1
- import { external_node_process_cwd, node_path, fileURLToPath, addTrailingSlash, PLUGIN_REACT_NAME, removeTrailingSlash, normalizeDarkMode, pluginVirtualModule, pluginReact, createRequire, MDX_OR_MD_REGEXP } from "../p~0.js";
1
+ import { external_node_process_cwd, node_path, fileURLToPath, addTrailingSlash, PLUGIN_REACT_NAME, removeTrailingSlash, normalizeDarkMode, pluginVirtualModule, pluginReact, createRequire, MDX_OR_MD_REGEXP } from "../8~0.js";
2
2
  import { createError } from "./utils/error.js";
3
3
  import { CSR_CLIENT_ENTRY, SSR_CLIENT_ENTRY, OUTPUT_DIR, SSG_MD_SERVER_ENTRY, NODE_SSG_BUNDLE_FOLDER, getInlineLocaleRedirectScript, isProduction, PACKAGE_ROOT, SSR_SERVER_ENTRY, TEMPLATE_PATH, NODE_SSG_MD_BUNDLE_FOLDER, DEFAULT_THEME, NODE_SSG_MD_BUNDLE_NAME, getInlineThemeScript, DEFAULT_TITLE, NODE_SSG_BUNDLE_NAME } from "./constants.js";
4
4
  import { isLlmsUIEnabled, isLlmsHintEnabled } from "./llms.js";
@@ -236,6 +236,11 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
236
236
  }
237
237
  },
238
238
  tools: {
239
+ rspack: {
240
+ experiments: {
241
+ runtimeMode: 'rspack'
242
+ }
243
+ },
239
244
  swc: {
240
245
  jsc: {
241
246
  transform: {
@@ -1,4 +1,4 @@
1
- import { node_path } from "../../p~0.js";
1
+ import { node_path } from "../../8~0.js";
2
2
  import { RouteService } from "./RouteService.js";
3
3
  import { getPageKey } from "../utils/getPageKey.js";
4
4
  import { slash } from "../utils/slash.js";
@@ -1,4 +1,4 @@
1
- import { RSPRESS_TEMP_DIR, node_path, removeTrailingSlash, promises, addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, glob } from "../../p~0.js";
1
+ import { RSPRESS_TEMP_DIR, node_path, removeTrailingSlash, promises, addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, glob } from "../../8~0.js";
2
2
  import { RoutePage, absolutePathToRoutePath, absolutePathToRelativePath } from "./RoutePage.js";
3
3
  import { createError } from "../utils/error.js";
4
4
  import { getRouteChunkName } from "./routeChunkAssets.js";
@@ -1,4 +1,4 @@
1
- import { unified, node_path, promises, loadFrontMatter, extractTextAndId, remark_gfm, remark_parse, MDX_OR_MD_REGEXP } from "../../p~0.js";
1
+ import { unified, node_path, promises, loadFrontMatter, extractTextAndId, remark_gfm, remark_mdx, MDX_OR_MD_REGEXP, remark_parse } from "../../8~0.js";
2
2
  import { applyReplaceRules } from "../utils/applyReplaceRules.js";
3
3
  import { flattenMdxContent } from "../utils/flattenMdxContent.js";
4
4
  import { importStatementRegex } from "../constants.js";
@@ -9,6 +9,7 @@ function applyReplaceRulesToNestedObject(obj, replaceRules) {
9
9
  return obj;
10
10
  }
11
11
  const processor = unified().use(remark_parse).use(remark_gfm);
12
+ const mdxProcessor = unified().use(remark_parse).use(remark_gfm).use(remark_mdx);
12
13
  function extractTextFromNode(node) {
13
14
  if ('value' in node && 'string' == typeof node.value) return node.value;
14
15
  if ('children' in node && Array.isArray(node.children)) return node.children.map(extractTextFromNode).join('');
@@ -99,6 +100,9 @@ const SKIP_NODE_TYPES = new Set([
99
100
  'html',
100
101
  'mdxjsEsm',
101
102
  'mdxFlowExpression',
103
+ 'mdxJsxFlowElement',
104
+ 'mdxJsxTextElement',
105
+ 'mdxTextExpression',
102
106
  'thematicBreak',
103
107
  'image',
104
108
  'table'
@@ -138,7 +142,7 @@ function extractDescription(tree) {
138
142
  if ('heading' === node.type && 2 === node.depth) break;
139
143
  if (!SKIP_NODE_TYPES.has(node.type)) {
140
144
  if (foundH1) {
141
- const text = extractTextFromNode(node).trim();
145
+ const text = extractDescriptionText(node).trim();
142
146
  if (text) textParts.push(text);
143
147
  }
144
148
  }
@@ -146,6 +150,18 @@ function extractDescription(tree) {
146
150
  const joined = textParts.join('\n');
147
151
  return stripContainerDirectives(joined).split('\n').map((l)=>l.trim()).filter(Boolean).join(' ');
148
152
  }
153
+ function extractDescriptionText(node) {
154
+ if (SKIP_NODE_TYPES.has(node.type)) return '';
155
+ if ('children' in node && Array.isArray(node.children)) return node.children.map(extractDescriptionText).join('');
156
+ return extractTextFromNode(node);
157
+ }
158
+ function parsePageTree(content) {
159
+ try {
160
+ return mdxProcessor.parse(content);
161
+ } catch {
162
+ return processor.parse(content);
163
+ }
164
+ }
149
165
  async function getPageIndexInfoByRoute(route, options) {
150
166
  const { alias, replaceRules, root, searchCodeBlocks, extractDescription: extractDescriptionConfig = true, searchEnabled = true } = options;
151
167
  const defaultIndexInfo = {
@@ -167,7 +183,7 @@ async function getPageIndexInfoByRoute(route, options) {
167
183
  const { flattenContent } = await flattenMdxContent(applyReplaceRules(contentWithoutFrontMatter, replaceRules), route.absolutePath, alias);
168
184
  content = flattenContent.replace(importStatementRegex, '');
169
185
  content = content.replace(/\r\n/g, '\n');
170
- const tree = processor.parse(content);
186
+ const tree = parsePageTree(content);
171
187
  const { title, toc: rawToc } = parseToc(tree);
172
188
  const extractedDescription = frontmatter.description || !extractDescriptionConfig ? '' : extractDescription(tree);
173
189
  if (!searchEnabled) return {
@@ -1,4 +1,4 @@
1
- import { addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, addLeadingSlash } from "../../p~0.js";
1
+ import { addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, addLeadingSlash } from "../../8~0.js";
2
2
  const getRoutePathParts = (relativePath, lang, version, langs, versions)=>{
3
3
  const [versionPart, langPart, purePath] = splitRoutePathParts(relativePath, lang, version, langs, versions);
4
4
  return [