@rspress/core 2.0.0-beta.0 → 2.0.0-beta.10
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/README.md +1 -1
- package/dist/index.d.ts +153 -0
- package/dist/index.js +386 -436
- package/dist/loader.d.ts +2 -5
- package/dist/loader.js +93 -269
- package/dist/runtime/App.d.ts +1 -4
- package/dist/runtime/App.js +3 -6
- package/dist/runtime/ClientApp.js +6 -1
- package/dist/runtime/csrClientEntry.js +3 -11
- package/dist/runtime/initPageData.d.ts +0 -1
- package/dist/runtime/initPageData.js +3 -6
- package/dist/runtime/ssrClientEntry.js +4 -11
- package/dist/runtime/ssrServerEntry.d.ts +3 -2
- package/dist/runtime/ssrServerEntry.js +7 -5
- package/package.json +28 -25
- package/dist/runtime/tsconfig.js +0 -4
package/dist/loader.d.ts
CHANGED
|
@@ -7,8 +7,6 @@ import type { Rspack as Rspack_2 } from '@rsbuild/core';
|
|
|
7
7
|
import type { RspressPlugin } from '@rspress/shared';
|
|
8
8
|
import type { UserConfig } from '@rspress/shared';
|
|
9
9
|
|
|
10
|
-
export declare function createCheckPageMetaUpdateFn(): (modulePath: string, pageMeta: PageMeta) => void;
|
|
11
|
-
|
|
12
10
|
declare interface LoaderOptions {
|
|
13
11
|
config: UserConfig;
|
|
14
12
|
docDirectory: string;
|
|
@@ -42,6 +40,7 @@ declare class PluginDriver {
|
|
|
42
40
|
extendPageData(pageData: PageIndexInfo): Promise<void[]>;
|
|
43
41
|
addPages(): Promise<AdditionalPage[]>;
|
|
44
42
|
routeGenerated(routes: RouteMeta[]): Promise<void[]>;
|
|
43
|
+
routeServiceGenerated(routeService: RouteService): Promise<void[]>;
|
|
45
44
|
addRuntimeModules(): Promise<Record<string, string>>;
|
|
46
45
|
addSSGRoutes(): Promise<({
|
|
47
46
|
path: string;
|
|
@@ -75,7 +74,7 @@ declare class RouteService {
|
|
|
75
74
|
};
|
|
76
75
|
}
|
|
77
76
|
|
|
78
|
-
declare type RspressPluginHookKeys = 'beforeBuild' | 'afterBuild' | 'addPages' | 'addRuntimeModules' | 'routeGenerated' | 'addSSGRoutes' | 'extendPageData' | 'modifySearchIndexData';
|
|
77
|
+
declare type RspressPluginHookKeys = 'beforeBuild' | 'afterBuild' | 'addPages' | 'addRuntimeModules' | 'routeGenerated' | 'routeServiceGenerated' | 'addSSGRoutes' | 'extendPageData' | 'modifySearchIndexData';
|
|
79
78
|
|
|
80
79
|
declare interface TocItem {
|
|
81
80
|
id: string;
|
|
@@ -83,6 +82,4 @@ declare interface TocItem {
|
|
|
83
82
|
depth: number;
|
|
84
83
|
}
|
|
85
84
|
|
|
86
|
-
export declare function updateSiteDataRuntimeModule(modulePath: string, pageMeta: PageMeta): Promise<void>;
|
|
87
|
-
|
|
88
85
|
export { }
|
package/dist/loader.js
CHANGED
|
@@ -1,130 +1,19 @@
|
|
|
1
1
|
import __rslib_shim_module__ from 'module';
|
|
2
2
|
/*#__PURE__*/ import.meta.url;
|
|
3
|
-
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__ from "node:fs/promises";
|
|
4
3
|
import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
|
|
5
|
-
import * as __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__ from "node:url";
|
|
6
4
|
import * as __WEBPACK_EXTERNAL_MODULE__mdx_js_mdx_b904bd09__ from "@mdx-js/mdx";
|
|
7
|
-
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__ from "@rspress/shared";
|
|
8
5
|
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__ from "@rspress/shared/logger";
|
|
9
6
|
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__ from "@rspress/shared/node-utils";
|
|
10
|
-
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
|
|
11
|
-
import * as __WEBPACK_EXTERNAL_MODULE_enhanced_resolve_bf4706da__ from "enhanced-resolve";
|
|
12
7
|
import * as __WEBPACK_EXTERNAL_MODULE_node_os_74b4b876__ from "node:os";
|
|
13
8
|
import * as __WEBPACK_EXTERNAL_MODULE_rehype_external_links_09bed11a__ from "rehype-external-links";
|
|
9
|
+
import * as __WEBPACK_EXTERNAL_MODULE_rehype_raw_434f4cf9__ from "rehype-raw";
|
|
14
10
|
import * as __WEBPACK_EXTERNAL_MODULE_remark_gfm_073acf21__ from "remark-gfm";
|
|
15
|
-
import * as __WEBPACK_EXTERNAL_MODULE_unist_util_visit_555e002a__ from "unist-util-visit";
|
|
16
11
|
import * as __WEBPACK_EXTERNAL_MODULE_github_slugger_8e9a17cb__ from "github-slugger";
|
|
17
12
|
import * as __WEBPACK_EXTERNAL_MODULE_hast_util_heading_rank_cff646ba__ from "hast-util-heading-rank";
|
|
13
|
+
import * as __WEBPACK_EXTERNAL_MODULE_unist_util_visit_555e002a__ from "unist-util-visit";
|
|
14
|
+
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__ from "@rspress/shared";
|
|
18
15
|
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_constants_70084e62__ from "@rspress/shared/constants";
|
|
19
16
|
import * as __WEBPACK_EXTERNAL_MODULE_unist_util_visit_children_71921007__ from "unist-util-visit-children";
|
|
20
|
-
const importStatementRegex = /import\s+(.*?)\s+from\s+(['"])(.*?)(?:"|');?/gm;
|
|
21
|
-
`{
|
|
22
|
-
const saved = localStorage.getItem('${__WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.APPEARANCE_KEY}')
|
|
23
|
-
const preferDark = window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
24
|
-
const isDark = !saved || saved === 'auto' ? preferDark : saved === 'dark'
|
|
25
|
-
document.documentElement.classList.toggle('dark', isDark)
|
|
26
|
-
document.documentElement.classList.toggle('rp-dark', isDark)
|
|
27
|
-
document.documentElement.style.colorScheme = isDark ? 'dark' : 'light'
|
|
28
|
-
}`.replace(/\n/g, ';').replace(/\s{2,}/g, '');
|
|
29
|
-
const dirname = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname((0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.fileURLToPath)(new URL(import.meta.url)));
|
|
30
|
-
const PACKAGE_ROOT = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(dirname, '..');
|
|
31
|
-
__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(PACKAGE_ROOT, 'index.html');
|
|
32
|
-
__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(PACKAGE_ROOT, 'dist', 'runtime', 'csrClientEntry.js');
|
|
33
|
-
__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(PACKAGE_ROOT, 'dist', 'runtime', 'ssrClientEntry.js');
|
|
34
|
-
__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(PACKAGE_ROOT, 'dist', 'runtime', 'ssrServerEntry.js');
|
|
35
|
-
const TEMP_DIR = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(process.cwd(), 'node_modules', __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.RSPRESS_TEMP_DIR);
|
|
36
|
-
var types_RuntimeModuleID = /*#__PURE__*/ function(RuntimeModuleID) {
|
|
37
|
-
RuntimeModuleID["GlobalStyles"] = "virtual-global-styles";
|
|
38
|
-
RuntimeModuleID["GlobalComponents"] = "virtual-global-components";
|
|
39
|
-
RuntimeModuleID["RouteForClient"] = "virtual-routes";
|
|
40
|
-
RuntimeModuleID["RouteForSSR"] = "virtual-routes-ssr";
|
|
41
|
-
RuntimeModuleID["SiteData"] = "virtual-site-data";
|
|
42
|
-
RuntimeModuleID["SearchIndexHash"] = "virtual-search-index-hash";
|
|
43
|
-
RuntimeModuleID["I18nText"] = "virtual-i18n-text";
|
|
44
|
-
RuntimeModuleID["SearchHooks"] = "virtual-search-hooks";
|
|
45
|
-
RuntimeModuleID["PrismLanguages"] = "virtual-prism-languages";
|
|
46
|
-
return RuntimeModuleID;
|
|
47
|
-
}({});
|
|
48
|
-
let resolver;
|
|
49
|
-
let startFlatten = false;
|
|
50
|
-
const processor = (0, __WEBPACK_EXTERNAL_MODULE__mdx_js_mdx_b904bd09__.createProcessor)();
|
|
51
|
-
const { CachedInputFileSystem, ResolverFactory } = __WEBPACK_EXTERNAL_MODULE_enhanced_resolve_bf4706da__["default"];
|
|
52
|
-
const fileSystem = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"];
|
|
53
|
-
async function resolveDepPath(importPath, importer, alias) {
|
|
54
|
-
if (!resolver) resolver = ResolverFactory.createResolver({
|
|
55
|
-
fileSystem: new CachedInputFileSystem(fileSystem, 0),
|
|
56
|
-
extensions: [
|
|
57
|
-
'.mdx',
|
|
58
|
-
'.md'
|
|
59
|
-
],
|
|
60
|
-
alias
|
|
61
|
-
});
|
|
62
|
-
const resolveResult = await new Promise((resolve, reject)=>{
|
|
63
|
-
resolver.resolve({
|
|
64
|
-
importer
|
|
65
|
-
}, importer, importPath, {}, (err, filePath)=>{
|
|
66
|
-
if (err) return reject(err);
|
|
67
|
-
if (!filePath) return reject(new Error(`Empty result when resolving ${importPath} from ${importer}`));
|
|
68
|
-
return resolve(filePath);
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
return resolveResult;
|
|
72
|
-
}
|
|
73
|
-
async function flattenMdxContent(content, basePath, alias) {
|
|
74
|
-
const deps = [];
|
|
75
|
-
const regex = new RegExp(importStatementRegex);
|
|
76
|
-
if (!regex.test(content)) return {
|
|
77
|
-
flattenContent: content,
|
|
78
|
-
deps
|
|
79
|
-
};
|
|
80
|
-
if (!startFlatten) {
|
|
81
|
-
resolver = ResolverFactory.createResolver({
|
|
82
|
-
fileSystem: new CachedInputFileSystem(fileSystem, 0),
|
|
83
|
-
extensions: [
|
|
84
|
-
'.mdx',
|
|
85
|
-
'.md',
|
|
86
|
-
'.js'
|
|
87
|
-
],
|
|
88
|
-
alias
|
|
89
|
-
});
|
|
90
|
-
startFlatten = true;
|
|
91
|
-
}
|
|
92
|
-
let ast;
|
|
93
|
-
let result = content;
|
|
94
|
-
try {
|
|
95
|
-
ast = processor.parse(content);
|
|
96
|
-
} catch (e) {
|
|
97
|
-
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.debug('flattenMdxContent parse failed: \n', e);
|
|
98
|
-
return {
|
|
99
|
-
flattenContent: content,
|
|
100
|
-
deps
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
const importNodes = ast.children.filter((node)=>'mdxjsEsm' === node.type).flatMap((node)=>{
|
|
104
|
-
var _node_data_estree, _node_data;
|
|
105
|
-
return (null == (_node_data = node.data) ? void 0 : null == (_node_data_estree = _node_data.estree) ? void 0 : _node_data_estree.body) || [];
|
|
106
|
-
}).filter((node)=>'ImportDeclaration' === node.type);
|
|
107
|
-
for (const importNode of importNodes){
|
|
108
|
-
const id = importNode.specifiers[0].local.name;
|
|
109
|
-
const importPath = importNode.source.value;
|
|
110
|
-
let absoluteImportPath;
|
|
111
|
-
try {
|
|
112
|
-
absoluteImportPath = await resolveDepPath(importPath, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(basePath), alias);
|
|
113
|
-
} catch (_e) {
|
|
114
|
-
continue;
|
|
115
|
-
}
|
|
116
|
-
if (__WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.MDX_OR_MD_REGEXP.test(absoluteImportPath)) {
|
|
117
|
-
const importedContent = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].readFileSync(absoluteImportPath, 'utf-8');
|
|
118
|
-
const { flattenContent: replacedValue, deps: subDeps } = await flattenMdxContent(importedContent, absoluteImportPath, alias);
|
|
119
|
-
result = result.replace(new RegExp(`import\\s+${id}\\s+from\\s+['"](${importPath})['"];?`), '').replace(new RegExp(`<${id}\\s*/>`, 'g'), ()=>replacedValue);
|
|
120
|
-
deps.push(...subDeps, absoluteImportPath);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
return {
|
|
124
|
-
flattenContent: result,
|
|
125
|
-
deps
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
17
|
function applyReplaceRules(code = '', replaceRules = []) {
|
|
129
18
|
let result = code;
|
|
130
19
|
for (const rule of replaceRules)result = result.replace(rule.search, rule.replace);
|
|
@@ -141,24 +30,12 @@ function slash(p) {
|
|
|
141
30
|
function normalizePath(id) {
|
|
142
31
|
return __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].posix.normalize(isWindows ? slash(id) : id);
|
|
143
32
|
}
|
|
144
|
-
const rehypePluginCodeMeta = ()=>(tree)=>{
|
|
145
|
-
(0, __WEBPACK_EXTERNAL_MODULE_unist_util_visit_555e002a__.visit)(tree, 'element', (node)=>{
|
|
146
|
-
var _node_children_;
|
|
147
|
-
if ('pre' === node.tagName && (null == (_node_children_ = node.children[0]) ? void 0 : _node_children_.type) === 'element' && 'code' === node.children[0].tagName) {
|
|
148
|
-
var _codeNode_data;
|
|
149
|
-
const codeNode = node.children[0];
|
|
150
|
-
codeNode.properties ??= {};
|
|
151
|
-
codeNode.properties.meta = null == (_codeNode_data = codeNode.data) ? void 0 : _codeNode_data.meta;
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
};
|
|
155
33
|
const rehypeHeaderAnchor = ()=>{
|
|
156
34
|
const slugger = new __WEBPACK_EXTERNAL_MODULE_github_slugger_8e9a17cb__["default"]();
|
|
157
35
|
return (tree)=>{
|
|
158
36
|
(0, __WEBPACK_EXTERNAL_MODULE_unist_util_visit_555e002a__.visit)(tree, 'element', (node)=>{
|
|
159
|
-
var _node_properties;
|
|
160
37
|
if (!(0, __WEBPACK_EXTERNAL_MODULE_hast_util_heading_rank_cff646ba__.headingRank)(node)) return;
|
|
161
|
-
if (!
|
|
38
|
+
if (!node.properties?.id) {
|
|
162
39
|
const [text, customId] = collectHeaderText(node);
|
|
163
40
|
node.properties ??= {};
|
|
164
41
|
node.properties.id = customId || slugger.slug(text);
|
|
@@ -247,7 +124,7 @@ function checkLinks(links, filepath, root, routeService) {
|
|
|
247
124
|
if (!routeService.isExistRoute((0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.cleanUrl)(link))) errorInfos.push(`Internal link to "${link}" is dead, check it in "${relativePath}"`);
|
|
248
125
|
});
|
|
249
126
|
if (errorInfos.length > 0) {
|
|
250
|
-
|
|
127
|
+
errorInfos?.forEach((err)=>{
|
|
251
128
|
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.error(err);
|
|
252
129
|
});
|
|
253
130
|
if ((0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isProduction)()) throw new Error('Dead link found');
|
|
@@ -261,46 +138,52 @@ const remarkCheckDeadLinks = (checkLink)=>{
|
|
|
261
138
|
if (!url) return;
|
|
262
139
|
if (internalLinks.has(url)) return;
|
|
263
140
|
if (!url.startsWith('http://') && !url.startsWith('https://')) {
|
|
264
|
-
|
|
265
|
-
const { routePath: normalizeUrl } = routeService.normalizeRoutePath(null == (_url_split_join = url.split(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].sep).join('/')) ? void 0 : _url_split_join.split('#')[0]);
|
|
141
|
+
const { routePath: normalizeUrl } = routeService.normalizeRoutePath(url.split(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].sep).join('/')?.split('#')[0]);
|
|
266
142
|
internalLinks.add(normalizeUrl);
|
|
267
143
|
}
|
|
268
144
|
});
|
|
269
145
|
checkLinks(Array.from(internalLinks), vfile.path, root, routeService);
|
|
270
146
|
};
|
|
271
147
|
};
|
|
148
|
+
function normalizeLink(nodeUrl, routeService, relativePath, cleanUrls) {
|
|
149
|
+
if (!nodeUrl) return '';
|
|
150
|
+
if (nodeUrl.startsWith('#')) return `#${nodeUrl.slice(1)}`;
|
|
151
|
+
let { url, hash } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.parseUrl)(nodeUrl);
|
|
152
|
+
if ((0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isExternalUrl)(url)) return url + (hash ? `#${hash}` : '');
|
|
153
|
+
const extname = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].extname(url);
|
|
154
|
+
if ((routeService?.extensions ?? __WEBPACK_EXTERNAL_MODULE__rspress_shared_constants_70084e62__.DEFAULT_PAGE_EXTENSIONS).includes(extname)) url = url.replace(new RegExp(`\\${extname}$`), '');
|
|
155
|
+
if (url.startsWith('.')) url = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].posix.join((0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.slash)(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(relativePath)), url);
|
|
156
|
+
else if (routeService) {
|
|
157
|
+
const [pathVersion, pathLang] = routeService.getRoutePathParts((0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.slash)(relativePath));
|
|
158
|
+
const [urlVersion, urlLang, urlPath] = routeService.getRoutePathParts(url);
|
|
159
|
+
url = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.addLeadingSlash)(urlPath);
|
|
160
|
+
if (pathLang && urlLang !== pathLang) url = `/${pathLang}${url}`;
|
|
161
|
+
if (pathVersion && urlVersion !== pathVersion) url = `/${pathVersion}${url}`;
|
|
162
|
+
}
|
|
163
|
+
if ('boolean' == typeof cleanUrls) url = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.normalizeHref)(url, cleanUrls);
|
|
164
|
+
else {
|
|
165
|
+
url = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.normalizeHref)(url, false);
|
|
166
|
+
url = url.replace(/\.html$/, cleanUrls);
|
|
167
|
+
}
|
|
168
|
+
if (hash) url += `#${hash}`;
|
|
169
|
+
return url;
|
|
170
|
+
}
|
|
171
|
+
const normalizeImageUrl = (imageUrl)=>{
|
|
172
|
+
if ((0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isExternalUrl)(imageUrl) || imageUrl.startsWith('/')) return '';
|
|
173
|
+
return imageUrl;
|
|
174
|
+
};
|
|
272
175
|
const remarkPluginNormalizeLink = ({ root, cleanUrls, routeService })=>(tree, file)=>{
|
|
273
176
|
const images = [];
|
|
274
177
|
(0, __WEBPACK_EXTERNAL_MODULE_unist_util_visit_555e002a__.visit)(tree, 'link', (node)=>{
|
|
275
|
-
|
|
276
|
-
if (node.url.startsWith('#')) {
|
|
277
|
-
node.url = `#${node.url.slice(1)}`;
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
let { url, hash } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.parseUrl)(node.url);
|
|
281
|
-
if ((0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isExternalUrl)(url)) {
|
|
282
|
-
node.url = url + (hash ? `#${hash}` : '');
|
|
283
|
-
return;
|
|
284
|
-
}
|
|
285
|
-
const extname = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].extname(url);
|
|
286
|
-
if (((null == routeService ? void 0 : routeService.extensions) ?? __WEBPACK_EXTERNAL_MODULE__rspress_shared_constants_70084e62__.DEFAULT_PAGE_EXTENSIONS).includes(extname)) url = url.replace(new RegExp(`\\${extname}$`), '');
|
|
178
|
+
const { url: nodeUrl } = node;
|
|
287
179
|
const relativePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(root, file.path);
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
if (pathVersion && urlVersion !== pathVersion) url = `/${pathVersion}${url}`;
|
|
295
|
-
}
|
|
296
|
-
url = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.normalizeHref)(url, cleanUrls);
|
|
297
|
-
if (hash) url += `#${hash}`;
|
|
298
|
-
node.url = url;
|
|
180
|
+
node.url = normalizeLink(nodeUrl, routeService, relativePath, cleanUrls);
|
|
181
|
+
});
|
|
182
|
+
(0, __WEBPACK_EXTERNAL_MODULE_unist_util_visit_555e002a__.visit)(tree, 'definition', (node)=>{
|
|
183
|
+
const { url: nodeUrl } = node;
|
|
184
|
+
const relativePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(root, file.path);
|
|
185
|
+
node.url = normalizeLink(nodeUrl, routeService, relativePath, cleanUrls);
|
|
299
186
|
});
|
|
300
|
-
const normalizeImageUrl = (imageUrl)=>{
|
|
301
|
-
if ((0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isExternalUrl)(imageUrl) || imageUrl.startsWith('/')) return '';
|
|
302
|
-
return imageUrl;
|
|
303
|
-
};
|
|
304
187
|
const getMdxSrcAttribute = (tempVar)=>({
|
|
305
188
|
type: 'mdxJsxAttribute',
|
|
306
189
|
name: 'src',
|
|
@@ -348,7 +231,7 @@ const remarkPluginNormalizeLink = ({ root, cleanUrls, routeService })=>(tree, fi
|
|
|
348
231
|
(0, __WEBPACK_EXTERNAL_MODULE_unist_util_visit_555e002a__.visit)(tree, (node)=>{
|
|
349
232
|
if ('mdxJsxFlowElement' !== node.type && 'mdxJsxTextElement' !== node.type || 'img' !== node.name) return;
|
|
350
233
|
const srcAttr = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__.getNodeAttribute)(node, 'src', true);
|
|
351
|
-
if ('string' != typeof
|
|
234
|
+
if ('string' != typeof srcAttr?.value) return;
|
|
352
235
|
const imagePath = normalizeImageUrl(srcAttr.value);
|
|
353
236
|
if (!imagePath) return;
|
|
354
237
|
const tempVariableName = `image${images.length}`;
|
|
@@ -366,22 +249,10 @@ const parseToc = (tree)=>{
|
|
|
366
249
|
if (node.depth >= 1 && node.depth < 5) {
|
|
367
250
|
let customId = '';
|
|
368
251
|
const text = node.children.map((child)=>{
|
|
369
|
-
if ('link' === child.type)
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
}
|
|
373
|
-
if ('strong' === child.type) {
|
|
374
|
-
var _child_children1;
|
|
375
|
-
return `**${null == (_child_children1 = child.children) ? void 0 : _child_children1.map((item)=>item.value).join('')}**`;
|
|
376
|
-
}
|
|
377
|
-
if ('emphasis' === child.type) {
|
|
378
|
-
var _child_children2;
|
|
379
|
-
return `*${null == (_child_children2 = child.children) ? void 0 : _child_children2.map((item)=>item.value).join('')}*`;
|
|
380
|
-
}
|
|
381
|
-
if ('delete' === child.type) {
|
|
382
|
-
var _child_children3;
|
|
383
|
-
return `~~${null == (_child_children3 = child.children) ? void 0 : _child_children3.map((item)=>item.value).join('')}~~`;
|
|
384
|
-
}
|
|
252
|
+
if ('link' === child.type) return child.children?.map((item)=>item.value).join('');
|
|
253
|
+
if ('strong' === child.type) return `**${child.children?.map((item)=>item.value).join('')}**`;
|
|
254
|
+
if ('emphasis' === child.type) return `*${child.children?.map((item)=>item.value).join('')}*`;
|
|
255
|
+
if ('delete' === child.type) return `~~${child.children?.map((item)=>item.value).join('')}~~`;
|
|
385
256
|
if ('text' === child.type) {
|
|
386
257
|
const [textPart, idPart] = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__.extractTextAndId)(child.value);
|
|
387
258
|
customId = idPart;
|
|
@@ -416,29 +287,28 @@ const remarkPluginToc = function() {
|
|
|
416
287
|
if (title) data.pageMeta.title = title;
|
|
417
288
|
};
|
|
418
289
|
};
|
|
290
|
+
const rehypeCodeMeta = ()=>(tree)=>{
|
|
291
|
+
(0, __WEBPACK_EXTERNAL_MODULE_unist_util_visit_555e002a__.visit)(tree, 'element', (node)=>{
|
|
292
|
+
if ('pre' === node.tagName && node.children[0]?.type === 'element' && 'code' === node.children[0].tagName) {
|
|
293
|
+
const codeNode = node.children[0];
|
|
294
|
+
codeNode.properties.metastring = codeNode.data?.meta;
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
};
|
|
419
298
|
async function createMDXOptions(docDirectory, config, checkDeadLinks, routeService, filepath, pluginDriver) {
|
|
420
|
-
|
|
421
|
-
const cleanUrls =
|
|
422
|
-
const { remarkPlugins: remarkPluginsFromConfig = [], rehypePlugins: rehypePluginsFromConfig = [], globalComponents: globalComponentsFromConfig = [] } =
|
|
299
|
+
const format = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].extname(filepath).slice(1);
|
|
300
|
+
const cleanUrls = config?.route?.cleanUrls ?? false;
|
|
301
|
+
const { remarkPlugins: remarkPluginsFromConfig = [], rehypePlugins: rehypePluginsFromConfig = [], globalComponents: globalComponentsFromConfig = [] } = config?.markdown || {};
|
|
423
302
|
const rspressPlugins = pluginDriver.getPlugins();
|
|
424
|
-
const remarkPluginsFromPlugins = rspressPlugins.flatMap((plugin)=>
|
|
425
|
-
|
|
426
|
-
return (null == (_plugin_markdown = plugin.markdown) ? void 0 : _plugin_markdown.remarkPlugins) || [];
|
|
427
|
-
});
|
|
428
|
-
const rehypePluginsFromPlugins = rspressPlugins.flatMap((plugin)=>{
|
|
429
|
-
var _plugin_markdown;
|
|
430
|
-
return (null == (_plugin_markdown = plugin.markdown) ? void 0 : _plugin_markdown.rehypePlugins) || [];
|
|
431
|
-
});
|
|
303
|
+
const remarkPluginsFromPlugins = rspressPlugins.flatMap((plugin)=>plugin.markdown?.remarkPlugins || []);
|
|
304
|
+
const rehypePluginsFromPlugins = rspressPlugins.flatMap((plugin)=>plugin.markdown?.rehypePlugins || []);
|
|
432
305
|
const globalComponents = [
|
|
433
|
-
...rspressPlugins.flatMap((plugin)=>
|
|
434
|
-
var _plugin_markdown;
|
|
435
|
-
return (null == (_plugin_markdown = plugin.markdown) ? void 0 : _plugin_markdown.globalComponents) || [];
|
|
436
|
-
}),
|
|
306
|
+
...rspressPlugins.flatMap((plugin)=>plugin.markdown?.globalComponents || []),
|
|
437
307
|
...globalComponentsFromConfig
|
|
438
308
|
];
|
|
439
309
|
return {
|
|
440
310
|
providerImportSource: '@mdx-js/react',
|
|
441
|
-
format
|
|
311
|
+
format,
|
|
442
312
|
remarkPlugins: [
|
|
443
313
|
__WEBPACK_EXTERNAL_MODULE_remark_gfm_073acf21__["default"],
|
|
444
314
|
remarkPluginToc,
|
|
@@ -454,7 +324,7 @@ async function createMDXOptions(docDirectory, config, checkDeadLinks, routeServi
|
|
|
454
324
|
remarkCheckDeadLinks,
|
|
455
325
|
{
|
|
456
326
|
root: docDirectory,
|
|
457
|
-
base:
|
|
327
|
+
base: config?.base || '',
|
|
458
328
|
routeService
|
|
459
329
|
}
|
|
460
330
|
],
|
|
@@ -469,7 +339,15 @@ async function createMDXOptions(docDirectory, config, checkDeadLinks, routeServi
|
|
|
469
339
|
].filter(Boolean),
|
|
470
340
|
rehypePlugins: [
|
|
471
341
|
rehypeHeaderAnchor,
|
|
472
|
-
|
|
342
|
+
...'md' === format ? [
|
|
343
|
+
rehypeCodeMeta,
|
|
344
|
+
[
|
|
345
|
+
__WEBPACK_EXTERNAL_MODULE_rehype_raw_434f4cf9__["default"],
|
|
346
|
+
{
|
|
347
|
+
passThrough: __WEBPACK_EXTERNAL_MODULE__mdx_js_mdx_b904bd09__.nodeTypes
|
|
348
|
+
}
|
|
349
|
+
]
|
|
350
|
+
] : [],
|
|
473
351
|
[
|
|
474
352
|
__WEBPACK_EXTERNAL_MODULE_rehype_external_links_09bed11a__["default"],
|
|
475
353
|
{
|
|
@@ -482,95 +360,41 @@ async function createMDXOptions(docDirectory, config, checkDeadLinks, routeServi
|
|
|
482
360
|
]
|
|
483
361
|
};
|
|
484
362
|
}
|
|
485
|
-
async function updateSiteDataRuntimeModule(modulePath, pageMeta) {
|
|
486
|
-
const siteDataModulePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(TEMP_DIR, 'runtime', `${types_RuntimeModuleID.SiteData}.mjs`);
|
|
487
|
-
const { default: siteData } = await import((0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.pathToFileURL)(siteDataModulePath).href);
|
|
488
|
-
await __WEBPACK_EXTERNAL_MODULE_node_fs_promises_153e37e0__["default"].writeFile(siteDataModulePath, `export default ${JSON.stringify({
|
|
489
|
-
...siteData,
|
|
490
|
-
timestamp: Date.now().toString(),
|
|
491
|
-
pages: siteData.pages.map((page)=>page._filepath === modulePath ? {
|
|
492
|
-
...page,
|
|
493
|
-
...pageMeta
|
|
494
|
-
} : page)
|
|
495
|
-
}, null, 2)}`);
|
|
496
|
-
}
|
|
497
|
-
function createCheckPageMetaUpdateFn() {
|
|
498
|
-
const pageMetaMap = new Map();
|
|
499
|
-
return (modulePath, pageMeta)=>{
|
|
500
|
-
const prevMeta = pageMetaMap.get(modulePath);
|
|
501
|
-
const deserializedMeta = JSON.stringify(pageMeta);
|
|
502
|
-
pageMetaMap.set(modulePath, deserializedMeta);
|
|
503
|
-
if (!prevMeta) return;
|
|
504
|
-
if (prevMeta !== deserializedMeta) setTimeout(async ()=>{
|
|
505
|
-
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.info('Page metadata changed, page reloading...');
|
|
506
|
-
await updateSiteDataRuntimeModule(modulePath, pageMeta);
|
|
507
|
-
});
|
|
508
|
-
};
|
|
509
|
-
}
|
|
510
|
-
const checkPageMetaUpdate = createCheckPageMetaUpdateFn();
|
|
511
363
|
async function mdxLoader(source) {
|
|
512
|
-
var _config_markdown;
|
|
513
364
|
this.cacheable(true);
|
|
514
365
|
const callback = this.async();
|
|
515
366
|
const options = this.getOptions();
|
|
516
367
|
const filepath = this.resourcePath;
|
|
517
|
-
const { alias } = this._compiler.options.resolve;
|
|
518
368
|
const { config, docDirectory, checkDeadLinks, routeService, pluginDriver } = options;
|
|
519
|
-
const { frontmatter,
|
|
520
|
-
const
|
|
521
|
-
|
|
522
|
-
const replacedContent = applyReplaceRules(flattenContent, config.replaceRules);
|
|
523
|
-
const preprocessedContent = escapeMarkdownHeadingIds(replacedContent);
|
|
524
|
-
let enableMdxRs;
|
|
525
|
-
const mdxRs = (null == config ? void 0 : null == (_config_markdown = config.markdown) ? void 0 : _config_markdown.mdxRs) ?? true;
|
|
526
|
-
enableMdxRs = 'object' == typeof mdxRs ? 'function' == typeof (null == mdxRs ? void 0 : mdxRs.include) ? mdxRs.include(filepath) : true : mdxRs;
|
|
369
|
+
const { frontmatter, emptyLinesSource } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__.loadFrontMatter)(source, filepath, docDirectory, true);
|
|
370
|
+
const replacedSource = applyReplaceRules(emptyLinesSource, config.replaceRules);
|
|
371
|
+
const preprocessedContent = escapeMarkdownHeadingIds(replacedSource);
|
|
527
372
|
try {
|
|
528
|
-
let compileResult;
|
|
529
373
|
let pageMeta = {
|
|
530
374
|
title: '',
|
|
531
375
|
toc: [],
|
|
532
376
|
headingTitle: ''
|
|
533
377
|
};
|
|
534
378
|
const frontmatterTitle = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__.extractTextAndId)(frontmatter.title)[0];
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
const compiler = (0, __WEBPACK_EXTERNAL_MODULE__mdx_js_mdx_b904bd09__.createProcessor)(mdxOptions);
|
|
555
|
-
compiler.data('pageMeta', {
|
|
556
|
-
toc: [],
|
|
557
|
-
title: ''
|
|
558
|
-
});
|
|
559
|
-
const vFile = await compiler.process({
|
|
560
|
-
value: preprocessedContent,
|
|
561
|
-
path: filepath
|
|
562
|
-
});
|
|
563
|
-
compileResult = String(vFile);
|
|
564
|
-
const compilationMeta = compiler.data('pageMeta');
|
|
565
|
-
const headingTitle = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__.extractTextAndId)(compilationMeta.title)[0];
|
|
566
|
-
pageMeta = {
|
|
567
|
-
...compilationMeta,
|
|
568
|
-
title: frontmatterTitle || headingTitle,
|
|
569
|
-
headingTitle,
|
|
570
|
-
frontmatter
|
|
571
|
-
};
|
|
572
|
-
}
|
|
573
|
-
if (!(0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isProduction)()) checkPageMetaUpdate(filepath, pageMeta);
|
|
379
|
+
const mdxOptions = await createMDXOptions(docDirectory, config, checkDeadLinks, routeService, filepath, pluginDriver);
|
|
380
|
+
const compiler = (0, __WEBPACK_EXTERNAL_MODULE__mdx_js_mdx_b904bd09__.createProcessor)(mdxOptions);
|
|
381
|
+
compiler.data('pageMeta', {
|
|
382
|
+
toc: [],
|
|
383
|
+
title: ''
|
|
384
|
+
});
|
|
385
|
+
const vFile = await compiler.process({
|
|
386
|
+
value: preprocessedContent,
|
|
387
|
+
path: filepath
|
|
388
|
+
});
|
|
389
|
+
const compileResult = String(vFile);
|
|
390
|
+
const compilationMeta = compiler.data('pageMeta');
|
|
391
|
+
const headingTitle = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__.extractTextAndId)(compilationMeta.title)[0];
|
|
392
|
+
pageMeta = {
|
|
393
|
+
...compilationMeta,
|
|
394
|
+
title: frontmatterTitle || headingTitle,
|
|
395
|
+
headingTitle,
|
|
396
|
+
frontmatter
|
|
397
|
+
};
|
|
574
398
|
const result = `const frontmatter = ${JSON.stringify(frontmatter)};
|
|
575
399
|
${compileResult}
|
|
576
400
|
MDXContent.__RSPRESS_PAGE_META = {};
|
|
@@ -589,4 +413,4 @@ MDXContent.__RSPRESS_PAGE_META["${encodeURIComponent(normalizePath(__WEBPACK_EXT
|
|
|
589
413
|
}
|
|
590
414
|
}
|
|
591
415
|
}
|
|
592
|
-
export {
|
|
416
|
+
export { mdxLoader as default };
|
package/dist/runtime/App.d.ts
CHANGED
package/dist/runtime/App.js
CHANGED
|
@@ -2,18 +2,16 @@ import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/j
|
|
|
2
2
|
import * as __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__ from "@rspress/runtime";
|
|
3
3
|
import * as __WEBPACK_EXTERNAL_MODULE__theme_75e53063__ from "@theme";
|
|
4
4
|
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
5
|
-
import * as __WEBPACK_EXTERNAL_MODULE_react_helmet_async_048d06c6__ from "react-helmet-async";
|
|
6
5
|
import * as __WEBPACK_EXTERNAL_MODULE_virtual_global_components_43dbb356__ from "virtual-global-components";
|
|
7
|
-
import "virtual-global-styles";
|
|
8
6
|
import * as __WEBPACK_EXTERNAL_MODULE__initPageData_js_731596b5__ from "./initPageData.js";
|
|
9
|
-
function App(
|
|
7
|
+
function App() {
|
|
10
8
|
const { setData: setPageData, data } = (0, __WEBPACK_EXTERNAL_MODULE_react__.useContext)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.DataContext);
|
|
11
9
|
const { pathname, search } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.useLocation)();
|
|
12
10
|
(0, __WEBPACK_EXTERNAL_MODULE_react__.useLayoutEffect)(()=>{
|
|
13
11
|
async function refetchData() {
|
|
14
12
|
try {
|
|
15
13
|
const pageData = await (0, __WEBPACK_EXTERNAL_MODULE__initPageData_js_731596b5__.initPageData)(pathname);
|
|
16
|
-
|
|
14
|
+
setPageData?.(pageData);
|
|
17
15
|
} catch (e) {
|
|
18
16
|
console.log(e);
|
|
19
17
|
}
|
|
@@ -28,8 +26,7 @@ function App({ helmetContext }) {
|
|
|
28
26
|
const GLOBAL_COMPONENTS_KEY = 'globalUIComponents';
|
|
29
27
|
const query = new URLSearchParams(search);
|
|
30
28
|
const hideGlobalUIComponents = false === frontmatter[GLOBAL_COMPONENTS_KEY] || "0" === query.get(GLOBAL_COMPONENTS_KEY);
|
|
31
|
-
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(
|
|
32
|
-
context: helmetContext,
|
|
29
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.Fragment, {
|
|
33
30
|
children: [
|
|
34
31
|
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__theme_75e53063__.Layout, {}),
|
|
35
32
|
!hideGlobalUIComponents && __WEBPACK_EXTERNAL_MODULE_virtual_global_components_43dbb356__["default"].map((componentInfo, index)=>{
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime";
|
|
2
2
|
import * as __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__ from "@rspress/runtime";
|
|
3
3
|
import * as __WEBPACK_EXTERNAL_MODULE__theme_75e53063__ from "@theme";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE__unhead_react_client_2b506c0d__ from "@unhead/react/client";
|
|
4
5
|
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
5
6
|
import * as __WEBPACK_EXTERNAL_MODULE__App_js_3638e61b__ from "./App.js";
|
|
7
|
+
const head = (0, __WEBPACK_EXTERNAL_MODULE__unhead_react_client_2b506c0d__.createHead)();
|
|
6
8
|
function ClientApp({ initialPageData = null }) {
|
|
7
9
|
const [data, setData] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(initialPageData);
|
|
8
10
|
const [theme, setTheme] = (0, __WEBPACK_EXTERNAL_MODULE__theme_75e53063__.useThemeState)();
|
|
@@ -23,7 +25,10 @@ function ClientApp({ initialPageData = null }) {
|
|
|
23
25
|
setData
|
|
24
26
|
]),
|
|
25
27
|
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.BrowserRouter, {
|
|
26
|
-
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(
|
|
28
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__unhead_react_client_2b506c0d__.UnheadProvider, {
|
|
29
|
+
head: head,
|
|
30
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__App_js_3638e61b__.App, {})
|
|
31
|
+
})
|
|
27
32
|
})
|
|
28
33
|
})
|
|
29
34
|
});
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_dom_client_76b1397c__ from "react-dom/client";
|
|
2
3
|
import * as __WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__ from "./ClientApp.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (process.env.__REACT_GTE_18__) {
|
|
6
|
-
const { createRoot } = await import("react-dom/client");
|
|
7
|
-
createRoot(container).render(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__.ClientApp, {}));
|
|
8
|
-
} else {
|
|
9
|
-
const ReactDOM = await import("react-dom");
|
|
10
|
-
ReactDOM.render(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__.ClientApp, {}), container);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
renderInBrowser();
|
|
4
|
+
const container = document.getElementById('root');
|
|
5
|
+
(0, __WEBPACK_EXTERNAL_MODULE_react_dom_client_76b1397c__.createRoot)(container).render(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__ClientApp_js_4935dbba__.ClientApp, {}));
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import * as __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__ from "@rspress/runtime";
|
|
2
2
|
import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__ from "@rspress/shared";
|
|
3
|
-
import "virtual-global-styles";
|
|
4
3
|
import * as __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__ from "virtual-site-data";
|
|
5
4
|
async function initPageData(routePath) {
|
|
6
|
-
var _siteData_multiVersion;
|
|
7
5
|
const matchedRoute = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.pathnameToRouteService)(routePath);
|
|
8
6
|
if (matchedRoute) {
|
|
9
|
-
var _mod_default___RSPRESS_PAGE_META;
|
|
10
7
|
const mod = await matchedRoute.preload();
|
|
11
8
|
const pagePath = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.cleanUrl)(matchedRoute.filePath);
|
|
12
9
|
const normalize = (p)=>p.replace(/\/$/, '').toLowerCase();
|
|
13
10
|
const extractPageInfo = __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].pages.find((page)=>(0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.isEqualPath)(normalize(page.routePath), normalize(matchedRoute.path)));
|
|
14
11
|
const encodedPagePath = encodeURIComponent(pagePath);
|
|
15
|
-
const meta =
|
|
12
|
+
const meta = mod.default.__RSPRESS_PAGE_META?.[encodedPagePath] || {};
|
|
16
13
|
const { toc = [], title = '', frontmatter = {}, ...rest } = __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.MDX_OR_MD_REGEXP.test(matchedRoute.filePath) ? meta : mod;
|
|
17
14
|
return {
|
|
18
15
|
siteData: __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"],
|
|
@@ -20,7 +17,7 @@ async function initPageData(routePath) {
|
|
|
20
17
|
...rest,
|
|
21
18
|
pagePath,
|
|
22
19
|
...extractPageInfo,
|
|
23
|
-
pageType:
|
|
20
|
+
pageType: frontmatter?.pageType || 'doc',
|
|
24
21
|
title,
|
|
25
22
|
frontmatter,
|
|
26
23
|
toc
|
|
@@ -28,7 +25,7 @@ async function initPageData(routePath) {
|
|
|
28
25
|
};
|
|
29
26
|
}
|
|
30
27
|
let lang = __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].lang || '';
|
|
31
|
-
let version =
|
|
28
|
+
let version = __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].multiVersion?.default || '';
|
|
32
29
|
if (__WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].lang && 'undefined' != typeof window) {
|
|
33
30
|
const path = location.pathname.replace(__WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].base, '').split('/').slice(0, 2);
|
|
34
31
|
if (__WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].locales.length) {
|