@rspress/core 2.0.12 → 2.0.13

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 (99) hide show
  1. package/dist/0~execa.js +1 -1
  2. package/dist/{8857.js → 5580.js} +2 -2
  3. package/dist/{1688.js → 7275.js} +6 -1
  4. package/dist/{8006.js → 7986.js} +1 -6
  5. package/dist/cli/index.js +4 -4
  6. package/dist/config/loadConfigFile.js +1 -1
  7. package/dist/eject-theme/components/CodeBlock/index.test.tsx +49 -0
  8. package/dist/eject-theme/components/CodeBlock/index.tsx +1 -1
  9. package/dist/eject-theme/components/CodeButtonGroup/index.tsx +5 -2
  10. package/dist/eject-theme/components/FallbackHeading/index.test.tsx +45 -0
  11. package/dist/eject-theme/components/FallbackHeading/index.tsx +1 -1
  12. package/dist/eject-theme/components/Link/useLinkNavigate.ts +2 -2
  13. package/dist/eject-theme/components/Overview/index.test.tsx +57 -0
  14. package/dist/eject-theme/components/Overview/index.tsx +1 -1
  15. package/dist/eject-theme/components/OverviewGroup/index.test.tsx +61 -0
  16. package/dist/eject-theme/components/OverviewGroup/index.tsx +1 -1
  17. package/dist/eject-theme/components/PackageManagerTabs/index.test.tsx +54 -0
  18. package/dist/eject-theme/components/PackageManagerTabs/index.tsx +1 -1
  19. package/dist/eject-theme/components/Steps/index.scss +6 -4
  20. package/dist/eject-theme/components/Tabs/index.test.tsx +51 -0
  21. package/dist/eject-theme/components/Tabs/index.tsx +1 -1
  22. package/dist/index.js +1 -1
  23. package/dist/node/PluginDriver.js +1 -1
  24. package/dist/node/auto-nav-sidebar/index.js +1 -1
  25. package/dist/node/auto-nav-sidebar/locales.js +1 -1
  26. package/dist/node/auto-nav-sidebar/normalize.js +3 -4
  27. package/dist/node/auto-nav-sidebar/utils.js +1 -1
  28. package/dist/node/auto-nav-sidebar/walk.js +1 -1
  29. package/dist/node/constants.js +3 -3
  30. package/dist/node/eject.js +2 -2
  31. package/dist/node/initRsbuild.js +5 -8
  32. package/dist/node/logger/hint.js +1 -1
  33. package/dist/node/mdx/options.js +1 -1
  34. package/dist/node/mdx/processor.js +1 -1
  35. package/dist/node/mdx/rehypePlugins/codeMeta.js +1 -1
  36. package/dist/node/mdx/rehypePlugins/headerAnchor.js +1 -1
  37. package/dist/node/mdx/rehypePlugins/shiki.js +1 -1
  38. package/dist/node/mdx/remarkPlugins/builtin.js +1 -1
  39. package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +2 -2
  40. package/dist/node/mdx/remarkPlugins/image.js +3 -4
  41. package/dist/node/mdx/remarkPlugins/link.js +2 -2
  42. package/dist/node/mdx/remarkPlugins/toc.js +1 -1
  43. package/dist/node/medium-zoom/index.js +1 -1
  44. package/dist/node/route/RoutePage.js +1 -1
  45. package/dist/node/route/RouteService.js +2 -3
  46. package/dist/node/route/extractPageData.js +1 -1
  47. package/dist/node/route/normalizeRoutePath.js +1 -1
  48. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.d.ts +119 -112
  49. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.js +7 -0
  50. package/dist/node/runtimeModule/i18n.js +2 -2
  51. package/dist/node/runtimeModule/pageData/createPageData.js +1 -1
  52. package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
  53. package/dist/node/runtimeModule/searchHooks.js +1 -1
  54. package/dist/node/runtimeModule/siteData/createSiteData.js +1 -1
  55. package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
  56. package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +1 -1
  57. package/dist/node/serve.js +1 -1
  58. package/dist/node/ssg/renderPage.js +2 -2
  59. package/dist/node/ssg/renderPageWorker.js +2 -2
  60. package/dist/node/ssg/renderPages.js +3 -3
  61. package/dist/node/ssg/rsbuildPluginSSG.js +1 -1
  62. package/dist/node/ssg/ssgEnv.js +1 -1
  63. package/dist/node/ssg-md/llms/emitLlmsTxt.js +1 -1
  64. package/dist/node/ssg-md/llms/llmsTxt.js +1 -1
  65. package/dist/node/ssg-md/remarkSplitMdx.js +1 -1
  66. package/dist/node/ssg-md/renderPage.js +2 -2
  67. package/dist/node/ssg-md/renderPages.js +3 -3
  68. package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -1
  69. package/dist/node/utils/checkLanguageParity.js +1 -1
  70. package/dist/node/utils/createHash.js +1 -1
  71. package/dist/node/utils/error.js +1 -1
  72. package/dist/node/utils/flattenMdxContent.js +1 -1
  73. package/dist/node/utils/fs.js +1 -1
  74. package/dist/node/utils/getPageKey.js +1 -1
  75. package/dist/node/utils/normalizePath.js +1 -1
  76. package/dist/node/utils/reactAlias.js +2 -2
  77. package/dist/runtime/App.js +1 -1
  78. package/dist/theme/components/CodeBlock/index.js +1 -1
  79. package/dist/theme/components/CodeButtonGroup/index.js +4 -2
  80. package/dist/theme/components/FallbackHeading/index.js +1 -1
  81. package/dist/theme/components/Link/useLinkNavigate.js +2 -2
  82. package/dist/theme/components/Overview/index.js +1 -1
  83. package/dist/theme/components/OverviewGroup/index.js +1 -1
  84. package/dist/theme/components/PackageManagerTabs/index.js +1 -1
  85. package/dist/theme/components/Steps/index.css +6 -4
  86. package/dist/theme/components/Tabs/index.js +1 -1
  87. package/dist/theme/layout/DocLayout/index.js +1 -1
  88. package/dist/theme/layout/HomeLayout/index.js +1 -1
  89. package/dist/theme/layout/Layout/index.js +1 -1
  90. package/package.json +6 -6
  91. package/dist/runtime/BrowserOnly.test.d.ts +0 -1
  92. /package/dist/{0~1402.js → 0~8787.js} +0 -0
  93. /package/dist/{2235.js → 2633.js} +0 -0
  94. /package/dist/{3323.js → 3358.js} +0 -0
  95. /package/dist/{8857.js.LICENSE.txt → 5580.js.LICENSE.txt} +0 -0
  96. /package/dist/{9224.js → 559.js} +0 -0
  97. /package/dist/{3294.js → 8005.js} +0 -0
  98. /package/dist/{6162.js → 9283.js} +0 -0
  99. /package/dist/{8474.js → 9882.js} +0 -0
package/dist/0~execa.js CHANGED
@@ -8,7 +8,7 @@ import { createReadStream, createWriteStream, readFileSync } from "node:fs";
8
8
  import { setTimeout as promises_setTimeout } from "node:timers/promises";
9
9
  import { debuglog } from "node:util";
10
10
  import { __webpack_require__ } from "./0~rslib-runtime.js";
11
- import "./2235.js";
11
+ import "./2633.js";
12
12
  __webpack_require__.add({
13
13
  "../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/index.js" (module, __unused_rspack_exports, __webpack_require__) {
14
14
  const cp = __webpack_require__("child_process");
@@ -1,6 +1,6 @@
1
- /*! LICENSE: 8857.js.LICENSE.txt */
1
+ /*! LICENSE: 5580.js.LICENSE.txt */
2
2
  import { __webpack_require__ } from "./0~rslib-runtime.js";
3
- import "./2235.js";
3
+ import "./2633.js";
4
4
  import { createRequire as __rspack_createRequire } from "node:module";
5
5
  const __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
6
6
  __webpack_require__.add({
@@ -1,3 +1,6 @@
1
+ var package_namespaceObject = {
2
+ rE: "2.0.13"
3
+ };
1
4
  async function pMap(iterable, mapper, { concurrency = 1 / 0, stopOnError = true, signal } = {}) {
2
5
  return new Promise((resolve_, reject_)=>{
3
6
  if (void 0 === iterable[Symbol.iterator] && void 0 === iterable[Symbol.asyncIterator]) throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof iterable})`);
@@ -89,7 +92,9 @@ async function pMap(iterable, mapper, { concurrency = 1 / 0, stopOnError = true,
89
92
  });
90
93
  }
91
94
  const pMapSkip = Symbol('skip');
95
+ export { createRequire } from "node:module";
96
+ export { default as node_path } from "node:path";
92
97
  export { pathToFileURL } from "node:url";
93
98
  export { logger } from "@rspress/shared/logger";
94
99
  export { createHead, transformHtmlTemplate } from "@unhead/react/server";
95
- export { pMap };
100
+ export { pMap, package_namespaceObject };
@@ -67,11 +67,6 @@ __webpack_require__.add({
67
67
  module.exports.createColors = createColors;
68
68
  }
69
69
  });
70
- var package_namespaceObject = {
71
- rE: "2.0.12"
72
- };
73
70
  export { default as promises, readFile } from "node:fs/promises";
74
- export { default as node_path, join, relative } from "node:path";
71
+ export { join, relative } from "node:path";
75
72
  export { logger } from "@rspress/shared/logger";
76
- export { createRequire } from "node:module";
77
- export { package_namespaceObject };
package/dist/cli/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { __webpack_require__ } from "../0~rslib-runtime.js";
2
- import { node_path, logger, join, cac } from "../8857.js";
3
- import { package_namespaceObject } from "../8006.js";
2
+ import { node_path, logger, join, cac } from "../5580.js";
3
+ import "../7986.js";
4
+ import { package_namespaceObject } from "../7275.js";
4
5
  import { loadConfigFile, resolveDocRoot } from "../config/loadConfigFile.js";
5
6
  import { dev } from "../node/dev.js";
6
- import { PUBLIC_DIR } from "../node/constants.js";
7
7
  import { build } from "../node/build.js";
8
8
  import { serve } from "../node/serve.js";
9
9
  import { listComponents, ejectComponent } from "../node/eject.js";
@@ -54,7 +54,7 @@ cli.command('[root]', 'start dev server').alias('dev').option('--port [port]', '
54
54
  '**/node_modules/**',
55
55
  '**/.git/**',
56
56
  '**/.DS_Store/**',
57
- join(docDirectory, PUBLIC_DIR)
57
+ join(docDirectory, "public")
58
58
  ]
59
59
  });
60
60
  cliWatcher.on('all', async (eventName, filepath)=>{
@@ -1,4 +1,4 @@
1
- import { node_fs, node_path, logger, DEFAULT_CONFIG_NAME, DEFAULT_CONFIG_EXTENSIONS } from "../8857.js";
1
+ import { node_fs, node_path, logger, DEFAULT_CONFIG_NAME, DEFAULT_CONFIG_EXTENSIONS } from "../5580.js";
2
2
  const findConfig = (basePath)=>DEFAULT_CONFIG_EXTENSIONS.map((ext)=>basePath + ext).find(node_fs.existsSync);
3
3
  async function loadConfigFile(customConfigFile) {
4
4
  const baseDir = process.cwd();
@@ -0,0 +1,49 @@
1
+ import { afterEach, describe, expect, it, rs } from '@rstest/core';
2
+ import { renderToMarkdownString } from 'react-render-to-markdown';
3
+ import { CodeBlock } from './index';
4
+
5
+ rs.mock('@rspress/core/theme', () => ({
6
+ CodeButtonGroup: () => null,
7
+ IconArrowDown: () => null,
8
+ SvgWrapper: () => null,
9
+ useCodeButtonGroup: () => ({
10
+ copyElementRef: { current: null },
11
+ toggleWrapCode: () => {},
12
+ wrapCode: false,
13
+ }),
14
+ }));
15
+
16
+ const originalSsgMd = import.meta.env.SSG_MD;
17
+
18
+ const setSsgMd = (value: boolean | undefined) => {
19
+ if (value === undefined) {
20
+ delete (import.meta.env as unknown as Record<string, unknown>).SSG_MD;
21
+ return;
22
+ }
23
+
24
+ (import.meta.env as unknown as Record<string, unknown>).SSG_MD = value;
25
+ };
26
+
27
+ afterEach(() => {
28
+ setSsgMd(originalSsgMd);
29
+ });
30
+
31
+ describe('CodeBlock', () => {
32
+ it('renders only its children when SSG_MD is enabled', async () => {
33
+ setSsgMd(true);
34
+
35
+ expect(
36
+ await renderToMarkdownString(
37
+ <CodeBlock title="example.ts">
38
+ <pre>const value = true;</pre>
39
+ </CodeBlock>,
40
+ ),
41
+ ).toMatchInlineSnapshot(`
42
+ "
43
+ \`\`\`\`
44
+ const value = true;
45
+ \`\`\`\`
46
+ "
47
+ `);
48
+ });
49
+ });
@@ -81,7 +81,7 @@ export function CodeBlock({
81
81
  codeButtonGroupProps,
82
82
  children,
83
83
  }: CodeBlockProps) {
84
- if (process.env.__SSR_MD__) {
84
+ if (import.meta.env.SSG_MD) {
85
85
  return <>{children}</>;
86
86
  }
87
87
 
@@ -1,4 +1,4 @@
1
- import { useSite } from '@rspress/core/runtime';
1
+ import { useI18n, useSite } from '@rspress/core/runtime';
2
2
  import { IconWrap, IconWrapped, SvgWrapper } from '@rspress/core/theme';
3
3
  import clsx from 'clsx';
4
4
  import { useRef, useState } from 'react';
@@ -43,6 +43,8 @@ export function CodeButtonGroup({
43
43
  showWrapCodeButton = true,
44
44
  showCopyButton = true,
45
45
  }: CodeButtonGroupProps) {
46
+ const t = useI18n();
47
+
46
48
  return (
47
49
  <>
48
50
  <div className="rp-code-button-group">
@@ -54,7 +56,8 @@ export function CodeButtonGroup({
54
56
  wrapCode && 'rp-code-wrap-button--wrapped',
55
57
  )}
56
58
  onClick={() => toggleWrapCode()}
57
- title="Toggle code wrap"
59
+ title={t('codeButtonGroupWrapButtonText')}
60
+ aria-label={t('codeButtonGroupWrapButtonText')}
58
61
  >
59
62
  <SvgWrapper
60
63
  icon={IconWrapped}
@@ -0,0 +1,45 @@
1
+ import { afterEach, describe, expect, it, rs } from '@rstest/core';
2
+ import { renderToMarkdownString } from 'react-render-to-markdown';
3
+ import { FallbackHeading } from './index';
4
+
5
+ rs.mock('@rspress/core/theme', () => ({
6
+ getCustomMDXComponent: () => ({
7
+ a: 'a',
8
+ h1: 'h1',
9
+ h2: 'h2',
10
+ h3: 'h3',
11
+ h4: 'h4',
12
+ h5: 'h5',
13
+ h6: 'h6',
14
+ }),
15
+ renderInlineMarkdown: (text: string) => ({
16
+ dangerouslySetInnerHTML: { __html: text },
17
+ }),
18
+ }));
19
+
20
+ const originalSsgMd = import.meta.env.SSG_MD;
21
+
22
+ const setSsgMd = (value: boolean | undefined) => {
23
+ if (value === undefined) {
24
+ delete (import.meta.env as unknown as Record<string, unknown>).SSG_MD;
25
+ return;
26
+ }
27
+
28
+ (import.meta.env as unknown as Record<string, unknown>).SSG_MD = value;
29
+ };
30
+
31
+ afterEach(() => {
32
+ setSsgMd(originalSsgMd);
33
+ });
34
+
35
+ describe('FallbackHeading', () => {
36
+ it('renders markdown when SSG_MD is enabled', async () => {
37
+ setSsgMd(true);
38
+
39
+ expect(
40
+ await renderToMarkdownString(
41
+ <FallbackHeading level={2} title="Getting Started" />,
42
+ ),
43
+ ).toBe('## Getting Started\n\n');
44
+ });
45
+ });
@@ -31,7 +31,7 @@ export function FallbackHeading({
31
31
  level: 1 | 2 | 3 | 4 | 5 | 6;
32
32
  title: string;
33
33
  }) {
34
- if (process.env.__SSR_MD__) {
34
+ if (import.meta.env.SSG_MD) {
35
35
  return <>{`${'#'.repeat(level)} ${title}\n\n`}</>;
36
36
  }
37
37
 
@@ -52,7 +52,7 @@ export function getHref(href: string): {
52
52
  return { linkType: linkType, withBaseHref: href, removeBaseHref: href };
53
53
  }
54
54
 
55
- if (linkType === 'relative' && !process.env.__SSR__) {
55
+ if (linkType === 'relative' && !import.meta.env.SSR) {
56
56
  withBaseHref = new URL(href, window.location.href).pathname;
57
57
  } else {
58
58
  withBaseHref = withBase(cleanUrlByConfig(href));
@@ -84,7 +84,7 @@ export function useLinkNavigate(
84
84
 
85
85
  const preloadChunkThenNavigate = async () => {
86
86
  const inCurrPage = isActive(removeBaseHref, currPagePathname);
87
- if (!process.env.__SSR__ && !inCurrPage) {
87
+ if (!import.meta.env.SSR && !inCurrPage) {
88
88
  const matchedRoute = pathnameToRouteService(removeBaseHref);
89
89
  if (matchedRoute) {
90
90
  const timer = setTimeout(() => {
@@ -0,0 +1,57 @@
1
+ import { afterEach, describe, expect, it, rs } from '@rstest/core';
2
+ import { renderToMarkdownString } from 'react-render-to-markdown';
3
+ import { Overview } from './index';
4
+
5
+ rs.mock('@rspress/core/runtime', () => ({
6
+ isEqualPath: (a: string, b: string) => a === b,
7
+ useI18n: () => (key: string) => key,
8
+ usePageData: () => ({
9
+ page: {
10
+ frontmatter: { overview: true },
11
+ routePath: '/guide/overview',
12
+ title: 'Guide Overview',
13
+ },
14
+ siteData: { pages: [] },
15
+ }),
16
+ useSidebar: () => [{ link: '/guide/overview', text: 'Overview' }],
17
+ }));
18
+
19
+ rs.mock('@rspress/core/theme', () => ({
20
+ FallbackHeading: ({ level, title }: { level: number; title: string }) =>
21
+ `${'#'.repeat(level)} ${title}\n\n`,
22
+ OverviewGroup: ({ group }: { group: { name: string } }) =>
23
+ `## ${group.name}\n\n`,
24
+ }));
25
+
26
+ const originalSsgMd = import.meta.env.SSG_MD;
27
+
28
+ const setSsgMd = (value: boolean | undefined) => {
29
+ if (value === undefined) {
30
+ delete (import.meta.env as unknown as Record<string, unknown>).SSG_MD;
31
+ return;
32
+ }
33
+
34
+ (import.meta.env as unknown as Record<string, unknown>).SSG_MD = value;
35
+ };
36
+
37
+ afterEach(() => {
38
+ setSsgMd(originalSsgMd);
39
+ });
40
+
41
+ describe('Overview', () => {
42
+ it('renders heading and groups as markdown when SSG_MD is enabled', async () => {
43
+ setSsgMd(true);
44
+
45
+ expect(
46
+ await renderToMarkdownString(
47
+ <Overview groups={[{ name: 'Guides', items: [] }]} />,
48
+ ),
49
+ ).toMatchInlineSnapshot(`
50
+ "# Guide Overview
51
+
52
+ ## Guides
53
+
54
+ "
55
+ `);
56
+ });
57
+ });
@@ -242,7 +242,7 @@ export function Overview(props: {
242
242
 
243
243
  const overviewTitle = title || 'Overview';
244
244
 
245
- if (process.env.__SSR_MD__) {
245
+ if (import.meta.env.SSG_MD) {
246
246
  return (
247
247
  <>
248
248
  <FallbackHeading level={1} title={overviewTitle} />
@@ -0,0 +1,61 @@
1
+ import { afterEach, describe, expect, it, rs } from '@rstest/core';
2
+ import { renderToMarkdownString } from 'react-render-to-markdown';
3
+ import { OverviewGroup, type Group } from './index';
4
+
5
+ rs.mock('@rspress/core/runtime', () => ({
6
+ routePathToMdPath: (routePath: string) => `${routePath}.md`,
7
+ }));
8
+
9
+ rs.mock('@rspress/core/theme', () => ({
10
+ FallbackHeading: () => null,
11
+ Link: 'a',
12
+ SvgWrapper: () => null,
13
+ renderInlineMarkdown: (text: string) => ({
14
+ dangerouslySetInnerHTML: { __html: text },
15
+ }),
16
+ }));
17
+
18
+ const originalSsgMd = import.meta.env.SSG_MD;
19
+
20
+ const setSsgMd = (value: boolean | undefined) => {
21
+ if (value === undefined) {
22
+ delete (import.meta.env as unknown as Record<string, unknown>).SSG_MD;
23
+ return;
24
+ }
25
+
26
+ (import.meta.env as unknown as Record<string, unknown>).SSG_MD = value;
27
+ };
28
+
29
+ afterEach(() => {
30
+ setSsgMd(originalSsgMd);
31
+ });
32
+
33
+ describe('OverviewGroup', () => {
34
+ it('renders overview links as markdown when SSG_MD is enabled', async () => {
35
+ setSsgMd(true);
36
+
37
+ const group: Group = {
38
+ name: 'Guide',
39
+ items: [
40
+ {
41
+ text: 'Introduction',
42
+ link: '/guide/introduction',
43
+ headers: [{ id: 'install', text: 'Install', depth: 2 }],
44
+ items: [{ text: 'Configuration', link: '/guide/configuration' }],
45
+ },
46
+ ],
47
+ };
48
+
49
+ expect(await renderToMarkdownString(<OverviewGroup group={group} />))
50
+ .toMatchInlineSnapshot(`
51
+ "## Guide
52
+
53
+ ### [Introduction](/guide/introduction.md)
54
+
55
+ - [Install](/guide/introduction.md#install)
56
+
57
+ - [Configuration](/guide/configuration.md)
58
+ "
59
+ `);
60
+ });
61
+ });
@@ -62,7 +62,7 @@ export interface Group {
62
62
  }
63
63
 
64
64
  export const OverviewGroup = ({ group }: { group: Group }) => {
65
- if (process.env.__SSR_MD__) {
65
+ if (import.meta.env.SSG_MD) {
66
66
  return <OverviewGroupMarkdown group={group} />;
67
67
  }
68
68
 
@@ -0,0 +1,54 @@
1
+ import { afterEach, describe, expect, it, rs } from '@rstest/core';
2
+ import type { ReactNode } from 'react';
3
+ import { renderToMarkdownString } from 'react-render-to-markdown';
4
+ import { PackageManagerTabs } from './index';
5
+
6
+ rs.mock('@rspress/core/theme', () => ({
7
+ getCustomMDXComponent: () => ({
8
+ pre: 'pre',
9
+ }),
10
+ Tab: ({ children }: { children: ReactNode }) => children,
11
+ Tabs: ({ children }: { children: ReactNode }) => children,
12
+ }));
13
+
14
+ const originalSsgMd = import.meta.env.SSG_MD;
15
+
16
+ const setSsgMd = (value: boolean | undefined) => {
17
+ if (value === undefined) {
18
+ delete (import.meta.env as unknown as Record<string, unknown>).SSG_MD;
19
+ return;
20
+ }
21
+
22
+ (import.meta.env as unknown as Record<string, unknown>).SSG_MD = value;
23
+ };
24
+
25
+ afterEach(() => {
26
+ setSsgMd(originalSsgMd);
27
+ });
28
+
29
+ describe('PackageManagerTabs', () => {
30
+ it('renders install commands as markdown code fences when SSG_MD is enabled', async () => {
31
+ setSsgMd(true);
32
+
33
+ expect(
34
+ await renderToMarkdownString(
35
+ <PackageManagerTabs
36
+ command={{
37
+ npm: 'npm install rspress',
38
+ pnpm: 'pnpm add rspress',
39
+ }}
40
+ />,
41
+ ),
42
+ ).toMatchInlineSnapshot(`
43
+ "
44
+ \`\`\`sh [npm]
45
+ npm install rspress
46
+ \`\`\`
47
+
48
+ \`\`\`sh [pnpm]
49
+ pnpm add rspress
50
+ \`\`\`
51
+ "
52
+ `);
53
+ });
54
+ });
@@ -218,7 +218,7 @@ export function PackageManagerTabs({
218
218
  commandInfo = command;
219
219
  }
220
220
 
221
- if (process.env.__SSR_MD__) {
221
+ if (import.meta.env.SSG_MD) {
222
222
  return Object.values(commandInfo).reduce((previous, current) => {
223
223
  const [packageManager, command] = splitTo2Parts(current);
224
224
  return (
@@ -1,6 +1,7 @@
1
1
  :root {
2
2
  --rp-steps-gap: 24px;
3
3
  --rp-steps-size: 30px;
4
+ --rp-steps-offset-y: 4px;
4
5
  }
5
6
 
6
7
  .rp-steps {
@@ -14,16 +15,15 @@
14
15
  counter-increment: step;
15
16
  margin-top: 0;
16
17
  position: relative;
17
- display: flex;
18
- align-items: center;
19
- min-height: 30px;
18
+ min-height: var(--rp-steps-size);
20
19
 
21
20
  &::before {
22
21
  // position
23
22
  content: counter(step);
24
23
  position: absolute;
24
+ top: calc(var(--rp-steps-size) / 2 + var(--rp-steps-offset-y));
25
25
  left: calc(-1 * var(--rp-steps-gap));
26
- transform: translate(-50%, 0);
26
+ transform: translate(-50%, -50%);
27
27
 
28
28
  // size
29
29
  width: var(--rp-steps-size);
@@ -48,7 +48,9 @@
48
48
  /* anchor link: move to the front and ensure it's clickable */
49
49
  .rp-header-anchor {
50
50
  position: absolute;
51
+ top: calc(var(--rp-steps-size) / 2 + var(--rp-steps-offset-y));
51
52
  left: calc(-1 * var(--rp-steps-gap) - var(--rp-steps-size) / 2);
53
+ transform: translate(0, -50%);
52
54
  }
53
55
  }
54
56
  }
@@ -0,0 +1,51 @@
1
+ import { afterEach, describe, expect, it, rs } from '@rstest/core';
2
+ import { renderToMarkdownString } from 'react-render-to-markdown';
3
+ import { Tab, Tabs } from './index';
4
+
5
+ rs.mock('@rspress/core/theme', () => ({
6
+ useStorageValue: () => ['0', () => {}],
7
+ }));
8
+
9
+ const originalSsgMd = import.meta.env.SSG_MD;
10
+
11
+ const setSsgMd = (value: boolean | undefined) => {
12
+ if (value === undefined) {
13
+ delete (import.meta.env as unknown as Record<string, unknown>).SSG_MD;
14
+ return;
15
+ }
16
+
17
+ (import.meta.env as unknown as Record<string, unknown>).SSG_MD = value;
18
+ };
19
+
20
+ afterEach(() => {
21
+ setSsgMd(originalSsgMd);
22
+ });
23
+
24
+ describe('Tabs', () => {
25
+ it('renders every tab as markdown when SSG_MD is enabled', async () => {
26
+ setSsgMd(true);
27
+
28
+ expect(
29
+ await renderToMarkdownString(
30
+ <Tabs>
31
+ <Tab label="npm" value="npm">
32
+ npm install
33
+ </Tab>
34
+ <Tab label="pnpm" value="pnpm">
35
+ pnpm install
36
+ </Tab>
37
+ </Tabs>,
38
+ ),
39
+ ).toMatchInlineSnapshot(`
40
+ "
41
+ **npm**
42
+
43
+ npm install
44
+
45
+ **pnpm**
46
+
47
+ pnpm install
48
+ "
49
+ `);
50
+ });
51
+ });
@@ -116,7 +116,7 @@ export const Tabs = forwardRef(
116
116
  return getTabValuesFromChildren(children, values);
117
117
  }, [children, values]);
118
118
 
119
- if (process.env.__SSR_MD__) {
119
+ if (import.meta.env.SSG_MD) {
120
120
  return (
121
121
  <>
122
122
  {tabValues.map(({ label, content }) => {
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export { PluginDriver } from "./node/PluginDriver.js";
2
- export { RSPRESS_TEMP_DIR, getIconUrlPath, getNodeAttribute, getSidebarDataGroup, logger, matchPath, mergeDocConfig, normalizeHref, normalizePosixPath, removeTrailingSlash, withBase } from "./8474.js";
2
+ export { RSPRESS_TEMP_DIR, getIconUrlPath, getNodeAttribute, getSidebarDataGroup, logger, matchPath, mergeDocConfig, normalizeHref, normalizePosixPath, removeTrailingSlash, withBase } from "./9882.js";
3
3
  export { RouteService } from "./node/route/RouteService.js";
4
4
  export { build } from "./node/build.js";
5
5
  export { defineConfig } from "./config/defineConfig.js";
@@ -1,4 +1,4 @@
1
- import { addTrailingSlash, node_path, addLeadingSlash } from "../2235.js";
1
+ import { addTrailingSlash, node_path, addLeadingSlash } from "../2633.js";
2
2
  import { createError } from "./utils/error.js";
3
3
  import { haveNavSidebarConfig as auto_nav_sidebar_haveNavSidebarConfig } from "./auto-nav-sidebar/index.js";
4
4
  class PluginDriver {
@@ -1,4 +1,4 @@
1
- import { DEFAULT_PAGE_EXTENSIONS, node_path } from "../../2235.js";
1
+ import { DEFAULT_PAGE_EXTENSIONS, node_path } from "../../2633.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 "../../2235.js";
1
+ import { node_path } from "../../2633.js";
2
2
  import { walk } from "./walk.js";
3
3
  function combineWalkResult(walks, versions) {
4
4
  return walks.reduce((acc, cur, curIndex)=>({
@@ -1,8 +1,7 @@
1
1
  import { __webpack_require__ } from "../../0~rslib-runtime.js";
2
- import "../../8006.js";
3
- import { extname, logger, promises_readdir, external_node_path_relative, isExternalUrl, slash, promises_stat, join } from "../../2235.js";
2
+ import "../../7986.js";
3
+ import { extname, logger, promises_readdir, external_node_path_relative, isExternalUrl, slash, promises_stat, join } from "../../2633.js";
4
4
  import { createError } from "../utils/error.js";
5
- import { PUBLIC_DIR } from "../constants.js";
6
5
  import { pathExists, extractInfoFromFrontmatterWithAbsolutePath, readJson } from "./utils.js";
7
6
  import { absolutePathToRoutePath, addRoutePrefix } from "../route/RoutePage.js";
8
7
  import { RouteService } from "../route/RouteService.js";
@@ -37,7 +36,7 @@ async function fsDirToMetaItems(workDir, docsDir, extensions) {
37
36
  if ('_meta.json' === item) return null;
38
37
  const stat = await promises_stat(join(workDir, item));
39
38
  if (stat.isDirectory()) {
40
- if (item === PUBLIC_DIR && workDir === docsDir) return null;
39
+ if ("public" === item && workDir === docsDir) return null;
41
40
  return {
42
41
  type: 'dir',
43
42
  name: item
@@ -1,4 +1,4 @@
1
- import { node_path, extractTextAndId, promises, loadFrontMatter } from "../../2235.js";
1
+ import { node_path, extractTextAndId, promises, loadFrontMatter } from "../../2633.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 "../../2235.js";
1
+ import { isExternalUrl, node_path, promises } from "../../2633.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,4 +1,4 @@
1
- import { createRequire, node_path, package_namespaceObject } from "../8006.js";
1
+ import { createRequire, node_path, package_namespaceObject } from "../7275.js";
2
2
  const constants_require = createRequire(import.meta.url);
3
3
  const RSPRESS_VERSION = package_namespaceObject.rE;
4
4
  const APPEARANCE_KEY = 'rspress-theme-appearance';
@@ -25,9 +25,9 @@ const APP_HTML_MARKER = '<!--<?- DOC_CONTENT ?>-->';
25
25
  const HEAD_MARKER = '<!--<?- HEAD ?>-->';
26
26
  const META_GENERATOR = '<!--<?- GENERATOR ?>-->';
27
27
  const DEFAULT_TITLE = 'Rspress';
28
- const PUBLIC_DIR = 'public';
29
28
  const NODE_SSG_BUNDLE_FOLDER = '__ssg__';
30
29
  const NODE_SSG_BUNDLE_NAME = 'rspress-ssg-entry.cjs';
31
30
  const NODE_SSG_MD_BUNDLE_FOLDER = '__ssg_md__';
32
31
  const NODE_SSG_MD_BUNDLE_NAME = 'rspress-ssg-md-entry.cjs';
33
- export { APP_HTML_MARKER, CSR_CLIENT_ENTRY, DEFAULT_THEME, DEFAULT_TITLE, EJECTED_THEME, HEAD_MARKER, META_GENERATOR, NODE_SSG_BUNDLE_FOLDER, NODE_SSG_BUNDLE_NAME, NODE_SSG_MD_BUNDLE_FOLDER, NODE_SSG_MD_BUNDLE_NAME, OUTPUT_DIR, PACKAGE_ROOT, PUBLIC_DIR, RSPRESS_VERSION, SSG_MD_SERVER_ENTRY, SSR_CLIENT_ENTRY, SSR_SERVER_ENTRY, TEMPLATE_PATH, importStatementRegex, inlineThemeScript, isProduction };
32
+ var constants_PUBLIC_DIR = "public";
33
+ export { APP_HTML_MARKER, CSR_CLIENT_ENTRY, DEFAULT_THEME, DEFAULT_TITLE, EJECTED_THEME, HEAD_MARKER, META_GENERATOR, NODE_SSG_BUNDLE_FOLDER, NODE_SSG_BUNDLE_NAME, NODE_SSG_MD_BUNDLE_FOLDER, NODE_SSG_MD_BUNDLE_NAME, OUTPUT_DIR, PACKAGE_ROOT, RSPRESS_VERSION, SSG_MD_SERVER_ENTRY, SSR_CLIENT_ENTRY, SSR_SERVER_ENTRY, TEMPLATE_PATH, constants_PUBLIC_DIR as PUBLIC_DIR, importStatementRegex, inlineThemeScript, isProduction };
@@ -1,6 +1,6 @@
1
1
  import { __webpack_require__ } from "../0~rslib-runtime.js";
2
- import "../8006.js";
3
- import { node_path, logger, promises } from "../8857.js";
2
+ import "../7986.js";
3
+ import { node_path, logger, promises } from "../5580.js";
4
4
  import { EJECTED_THEME } from "./constants.js";
5
5
  const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
6
6
  var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);