@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.
- package/dist/{0~7675.6e0caa9f.js → 0~7675.423f6a06.js} +2 -2
- package/dist/{5485.5f8db93a.js → 5485.7e481fde.js} +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/config/loadConfigFile.js +1 -1
- package/dist/eject-theme/components/Badge/index.tsx +1 -1
- package/dist/eject-theme/components/Button/index.tsx +1 -1
- package/dist/eject-theme/components/CodeBlock/index.scss +5 -1
- package/dist/eject-theme/components/DocContent/docComponents/title.tsx +7 -2
- package/dist/eject-theme/components/EditLink/index.scss +10 -8
- package/dist/eject-theme/components/EditLink/index.tsx +13 -4
- package/dist/eject-theme/components/HoverGroup/index.tsx +8 -2
- package/dist/eject-theme/components/Llms/LlmsCopyRow.tsx +51 -0
- package/dist/eject-theme/components/Llms/LlmsOpenRow.scss +10 -0
- package/dist/eject-theme/components/Llms/LlmsOpenRow.tsx +170 -0
- package/dist/eject-theme/components/Nav/NavMenu.tsx +7 -1
- package/dist/eject-theme/components/Nav/hooks.tsx +2 -0
- package/dist/eject-theme/components/NavScreen/NavScreenLangs.tsx +8 -1
- package/dist/eject-theme/components/NavScreen/NavScreenMenuItem.scss +0 -1
- package/dist/eject-theme/components/Outline/ScrollToTop.tsx +12 -34
- package/dist/eject-theme/components/Outline/index.scss +41 -5
- package/dist/eject-theme/components/Outline/index.tsx +19 -2
- package/dist/eject-theme/components/OverviewGroup/index.scss +5 -11
- package/dist/eject-theme/components/PackageManagerTabs/index.tsx +10 -2
- package/dist/eject-theme/components/Search/SearchPanel.tsx +2 -1
- package/dist/eject-theme/components/Search/logic/providers/LocalProvider.ts +1 -1
- package/dist/eject-theme/components/Sidebar/SidebarItem.scss +0 -2
- package/dist/eject-theme/components/SidebarMenu/index.scss +25 -1
- package/dist/eject-theme/components/SidebarMenu/index.tsx +5 -2
- package/dist/eject-theme/components/SourceCode/index.tsx +1 -1
- package/dist/eject-theme/components/SvgWrapper/index.tsx +5 -2
- package/dist/eject-theme/components/Tabs/index.scss +1 -1
- package/dist/eject-theme/components/Tabs/index.tsx +1 -1
- package/dist/eject-theme/components/Tag/index.tsx +2 -0
- package/dist/index.js +1 -1
- package/dist/node/auto-nav-sidebar/index.js +1 -1
- package/dist/node/auto-nav-sidebar/normalize.js +30 -4
- package/dist/node/constants.js +1 -1
- package/dist/node/initRsbuild.js +11 -9
- package/dist/node/last-updated/index.js +1 -1
- package/dist/node/logger/hint.d.ts +0 -3
- package/dist/node/logger/hint.js +8 -4
- package/dist/node/mdx/rehypePlugins/transformers/add-line-numbers.js +3 -2
- package/dist/node/mdx/rehypePlugins/transformers/add-wrap-code.js +4 -3
- package/dist/node/route/RouteService.js +1 -1
- package/dist/node/route/extractPageData.js +23 -2
- package/dist/node/route/normalizeRoutePath.js +1 -1
- package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.d.ts +4 -4
- package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.js +4 -4
- package/dist/node/runtimeModule/i18n.js +1 -1
- package/dist/node/runtimeModule/pageData/createPageData.js +2 -2
- package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
- package/dist/node/serve.js +1 -1
- package/dist/node/ssg/renderPage.js +1 -1
- package/dist/node/ssg/renderPageWorker.js +1 -1
- package/dist/node/ssg/renderPages.js +2 -2
- package/dist/node/ssg-md/llms/emitLlmsTxt.js +1 -1
- package/dist/node/ssg-md/remarkSplitMdx.js +11 -1
- package/dist/node/ssg-md/renderPage.js +4 -3
- package/dist/node/ssg-md/renderPages.js +1 -1
- package/dist/node/utils/createHash.js +1 -1
- package/dist/node/utils/flattenMdxContent.js +1 -1
- package/dist/node/utils/reactAlias.d.ts +1 -0
- package/dist/node/utils/reactAlias.js +34 -2
- package/dist/runtime/ssrMdServerEntry.js +1 -1
- package/dist/theme/assets/copy.js +3 -3
- package/dist/theme/assets/edit.js +18 -0
- package/dist/theme/assets/scroll-to-top.js +36 -0
- package/dist/theme/assets/success.js +3 -2
- package/dist/theme/components/Badge/index.d.ts +1 -2
- package/dist/theme/components/Button/index.d.ts +1 -2
- package/dist/theme/components/CodeBlock/index.css +5 -1
- package/dist/theme/components/DocContent/docComponents/title.js +5 -2
- package/dist/theme/components/EditLink/index.css +2 -2
- package/dist/theme/components/EditLink/index.d.ts +3 -1
- package/dist/theme/components/EditLink/index.js +18 -4
- package/dist/theme/components/HoverGroup/index.js +8 -1
- package/dist/theme/components/Llms/LlmsCopyRow.d.ts +1 -0
- package/dist/theme/components/Llms/LlmsCopyRow.js +50 -0
- package/dist/theme/components/Llms/LlmsOpenRow.css +11 -0
- package/dist/theme/components/Llms/LlmsOpenRow.d.ts +3 -0
- package/dist/theme/components/Llms/LlmsOpenRow.js +168 -0
- package/dist/theme/components/Nav/NavMenu.js +3 -0
- package/dist/theme/components/Nav/hooks.d.ts +2 -0
- package/dist/theme/components/Nav/hooks.js +3 -1
- package/dist/theme/components/NavScreen/NavScreenLangs.js +3 -0
- package/dist/theme/components/NavScreen/NavScreenMenuItem.css +0 -1
- package/dist/theme/components/Outline/ScrollToTop.d.ts +1 -2
- package/dist/theme/components/Outline/ScrollToTop.js +7 -32
- package/dist/theme/components/Outline/index.css +39 -4
- package/dist/theme/components/Outline/index.js +16 -4
- package/dist/theme/components/OverviewGroup/index.css +2 -9
- package/dist/theme/components/PackageManagerTabs/index.js +10 -3
- package/dist/theme/components/Search/SearchPanel.js +1 -1
- package/dist/theme/components/Search/logic/providers/LocalProvider.js +1 -1
- package/dist/theme/components/Sidebar/SidebarItem.css +0 -2
- package/dist/theme/components/SidebarMenu/index.css +25 -1
- package/dist/theme/components/SidebarMenu/index.js +3 -1
- package/dist/theme/components/SourceCode/index.d.ts +1 -2
- package/dist/theme/components/SvgWrapper/index.d.ts +1 -2
- package/dist/theme/components/SvgWrapper/index.js +2 -1
- package/dist/theme/components/Tabs/index.css +1 -1
- package/dist/theme/components/Tabs/index.d.ts +1 -1
- package/dist/theme/components/Tag/index.js +4 -0
- package/dist/theme/icons.d.ts +2 -0
- package/dist/theme/icons.js +5 -1
- package/dist/theme/index.d.ts +8 -5
- package/dist/theme/index.js +4 -1
- package/dist/theme/layout/DocLayout/index.css +3 -3
- package/dist/theme/layout/Layout/index.js +10 -4
- package/dist/theme/styles/base.css +4 -0
- package/nav-json-schema.json +12 -0
- package/package.json +14 -16
- package/dist/_private/react/index.js +0 -2
- package/dist/_private/react/reconciler.js +0 -169
- package/dist/_private/react/render.js +0 -118
- package/dist/eject-theme/components/Outline/ScrollToTop.scss +0 -13
- package/dist/node/ssg-md/react/index.d.ts +0 -1
- package/dist/node/ssg-md/react/reconciler.d.ts +0 -18
- package/dist/node/ssg-md/react/render.d.ts +0 -1
- package/dist/node/ssg-md/react/render.test.d.ts +0 -1
- package/dist/theme/components/Outline/ScrollToTop.css +0 -14
- /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:
|
|
99
|
-
max-width:
|
|
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 =
|
|
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,
|
|
@@ -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>
|
|
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',
|
|
@@ -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
|
|
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)} />;
|
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 "./
|
|
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 "../../
|
|
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)
|
|
46
|
-
|
|
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,
|
package/dist/node/constants.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createRequire, package_namespaceObject } from "../5485.
|
|
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;
|
package/dist/node/initRsbuild.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { createRequire, fileURLToPath, package_namespaceObject } from "../5485.
|
|
1
|
+
import { createRequire, fileURLToPath, package_namespaceObject } from "../5485.7e481fde.js";
|
|
2
2
|
import { node_path } from "../6289.29817fb4.js";
|
|
3
|
-
import {
|
|
4
|
-
import { PLUGIN_REACT_NAME, pluginReact, pluginVirtualModule } from "../
|
|
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() ?
|
|
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: {
|
|
@@ -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.
|
package/dist/node/logger/hint.js
CHANGED
|
@@ -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
|
-
|
|
61
|
-
|
|
62
|
-
2. Set
|
|
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)=>
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
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 "../../
|
|
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 "../../
|
|
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
|
-
|
|
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 "../../
|
|
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: "
|
|
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: '
|
|
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.
|
|
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 "../../../
|
|
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 "../../../
|
|
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 = {
|
package/dist/node/serve.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { mergeRsbuildConfig } from "../
|
|
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.
|
|
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.
|
|
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');
|