@rspress/core 2.0.0-beta.0 → 2.0.0-beta.1
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/index.d.ts +153 -0
- package/dist/index.js +335 -323
- package/dist/loader.d.ts +2 -1
- package/dist/loader.js +65 -116
- package/dist/runtime/App.js +1 -1
- package/dist/runtime/initPageData.js +3 -5
- package/package.json +13 -12
package/dist/loader.d.ts
CHANGED
|
@@ -42,6 +42,7 @@ declare class PluginDriver {
|
|
|
42
42
|
extendPageData(pageData: PageIndexInfo): Promise<void[]>;
|
|
43
43
|
addPages(): Promise<AdditionalPage[]>;
|
|
44
44
|
routeGenerated(routes: RouteMeta[]): Promise<void[]>;
|
|
45
|
+
routeServiceGenerated(routeService: RouteService): Promise<void[]>;
|
|
45
46
|
addRuntimeModules(): Promise<Record<string, string>>;
|
|
46
47
|
addSSGRoutes(): Promise<({
|
|
47
48
|
path: string;
|
|
@@ -75,7 +76,7 @@ declare class RouteService {
|
|
|
75
76
|
};
|
|
76
77
|
}
|
|
77
78
|
|
|
78
|
-
declare type RspressPluginHookKeys = 'beforeBuild' | 'afterBuild' | 'addPages' | 'addRuntimeModules' | 'routeGenerated' | 'addSSGRoutes' | 'extendPageData' | 'modifySearchIndexData';
|
|
79
|
+
declare type RspressPluginHookKeys = 'beforeBuild' | 'afterBuild' | 'addPages' | 'addRuntimeModules' | 'routeGenerated' | 'routeServiceGenerated' | 'addSSGRoutes' | 'extendPageData' | 'modifySearchIndexData';
|
|
79
80
|
|
|
80
81
|
declare interface TocItem {
|
|
81
82
|
id: string;
|
package/dist/loader.js
CHANGED
|
@@ -100,10 +100,7 @@ async function flattenMdxContent(content, basePath, alias) {
|
|
|
100
100
|
deps
|
|
101
101
|
};
|
|
102
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);
|
|
103
|
+
const importNodes = ast.children.filter((node)=>'mdxjsEsm' === node.type).flatMap((node)=>node.data?.estree?.body || []).filter((node)=>'ImportDeclaration' === node.type);
|
|
107
104
|
for (const importNode of importNodes){
|
|
108
105
|
const id = importNode.specifiers[0].local.name;
|
|
109
106
|
const importPath = importNode.source.value;
|
|
@@ -143,12 +140,10 @@ function normalizePath(id) {
|
|
|
143
140
|
}
|
|
144
141
|
const rehypePluginCodeMeta = ()=>(tree)=>{
|
|
145
142
|
(0, __WEBPACK_EXTERNAL_MODULE_unist_util_visit_555e002a__.visit)(tree, 'element', (node)=>{
|
|
146
|
-
|
|
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;
|
|
143
|
+
if ('pre' === node.tagName && node.children[0]?.type === 'element' && 'code' === node.children[0].tagName) {
|
|
149
144
|
const codeNode = node.children[0];
|
|
150
145
|
codeNode.properties ??= {};
|
|
151
|
-
codeNode.properties.meta =
|
|
146
|
+
codeNode.properties.meta = codeNode.data?.meta;
|
|
152
147
|
}
|
|
153
148
|
});
|
|
154
149
|
};
|
|
@@ -156,9 +151,8 @@ const rehypeHeaderAnchor = ()=>{
|
|
|
156
151
|
const slugger = new __WEBPACK_EXTERNAL_MODULE_github_slugger_8e9a17cb__["default"]();
|
|
157
152
|
return (tree)=>{
|
|
158
153
|
(0, __WEBPACK_EXTERNAL_MODULE_unist_util_visit_555e002a__.visit)(tree, 'element', (node)=>{
|
|
159
|
-
var _node_properties;
|
|
160
154
|
if (!(0, __WEBPACK_EXTERNAL_MODULE_hast_util_heading_rank_cff646ba__.headingRank)(node)) return;
|
|
161
|
-
if (!
|
|
155
|
+
if (!node.properties?.id) {
|
|
162
156
|
const [text, customId] = collectHeaderText(node);
|
|
163
157
|
node.properties ??= {};
|
|
164
158
|
node.properties.id = customId || slugger.slug(text);
|
|
@@ -247,7 +241,7 @@ function checkLinks(links, filepath, root, routeService) {
|
|
|
247
241
|
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
242
|
});
|
|
249
243
|
if (errorInfos.length > 0) {
|
|
250
|
-
|
|
244
|
+
errorInfos?.forEach((err)=>{
|
|
251
245
|
__WEBPACK_EXTERNAL_MODULE__rspress_shared_logger_4374e44a__.logger.error(err);
|
|
252
246
|
});
|
|
253
247
|
if ((0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isProduction)()) throw new Error('Dead link found');
|
|
@@ -261,46 +255,47 @@ const remarkCheckDeadLinks = (checkLink)=>{
|
|
|
261
255
|
if (!url) return;
|
|
262
256
|
if (internalLinks.has(url)) return;
|
|
263
257
|
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]);
|
|
258
|
+
const { routePath: normalizeUrl } = routeService.normalizeRoutePath(url.split(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].sep).join('/')?.split('#')[0]);
|
|
266
259
|
internalLinks.add(normalizeUrl);
|
|
267
260
|
}
|
|
268
261
|
});
|
|
269
262
|
checkLinks(Array.from(internalLinks), vfile.path, root, routeService);
|
|
270
263
|
};
|
|
271
264
|
};
|
|
265
|
+
function normalizeLink(nodeUrl, routeService, relativePath, cleanUrls) {
|
|
266
|
+
if (!nodeUrl) return '';
|
|
267
|
+
if (nodeUrl.startsWith('#')) return `#${nodeUrl.slice(1)}`;
|
|
268
|
+
let { url, hash } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.parseUrl)(nodeUrl);
|
|
269
|
+
if ((0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isExternalUrl)(url)) return url + (hash ? `#${hash}` : '');
|
|
270
|
+
const extname = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].extname(url);
|
|
271
|
+
if ((routeService?.extensions ?? __WEBPACK_EXTERNAL_MODULE__rspress_shared_constants_70084e62__.DEFAULT_PAGE_EXTENSIONS).includes(extname)) url = url.replace(new RegExp(`\\${extname}$`), '');
|
|
272
|
+
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);
|
|
273
|
+
else if (routeService) {
|
|
274
|
+
const [pathVersion, pathLang] = routeService.getRoutePathParts((0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.slash)(relativePath));
|
|
275
|
+
const [urlVersion, urlLang, urlPath] = routeService.getRoutePathParts(url);
|
|
276
|
+
url = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.addLeadingSlash)(urlPath);
|
|
277
|
+
if (pathLang && urlLang !== pathLang) url = `/${pathLang}${url}`;
|
|
278
|
+
if (pathVersion && urlVersion !== pathVersion) url = `/${pathVersion}${url}`;
|
|
279
|
+
}
|
|
280
|
+
if ('boolean' == typeof cleanUrls) url = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.normalizeHref)(url, cleanUrls);
|
|
281
|
+
else {
|
|
282
|
+
url = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.normalizeHref)(url, false);
|
|
283
|
+
url = url.replace(/\.html$/, cleanUrls);
|
|
284
|
+
}
|
|
285
|
+
if (hash) url += `#${hash}`;
|
|
286
|
+
return url;
|
|
287
|
+
}
|
|
288
|
+
const normalizeImageUrl = (imageUrl)=>{
|
|
289
|
+
if ((0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isExternalUrl)(imageUrl) || imageUrl.startsWith('/')) return '';
|
|
290
|
+
return imageUrl;
|
|
291
|
+
};
|
|
272
292
|
const remarkPluginNormalizeLink = ({ root, cleanUrls, routeService })=>(tree, file)=>{
|
|
273
293
|
const images = [];
|
|
274
294
|
(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}$`), '');
|
|
295
|
+
const { url: nodeUrl } = node;
|
|
287
296
|
const relativePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(root, file.path);
|
|
288
|
-
|
|
289
|
-
else if (routeService) {
|
|
290
|
-
const [pathVersion, pathLang] = routeService.getRoutePathParts((0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.slash)(relativePath));
|
|
291
|
-
const [urlVersion, urlLang, urlPath] = routeService.getRoutePathParts(url);
|
|
292
|
-
url = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.addLeadingSlash)(urlPath);
|
|
293
|
-
if (pathLang && urlLang !== pathLang) url = `/${pathLang}${url}`;
|
|
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;
|
|
297
|
+
node.url = normalizeLink(nodeUrl, routeService, relativePath, cleanUrls);
|
|
299
298
|
});
|
|
300
|
-
const normalizeImageUrl = (imageUrl)=>{
|
|
301
|
-
if ((0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isExternalUrl)(imageUrl) || imageUrl.startsWith('/')) return '';
|
|
302
|
-
return imageUrl;
|
|
303
|
-
};
|
|
304
299
|
const getMdxSrcAttribute = (tempVar)=>({
|
|
305
300
|
type: 'mdxJsxAttribute',
|
|
306
301
|
name: 'src',
|
|
@@ -348,7 +343,7 @@ const remarkPluginNormalizeLink = ({ root, cleanUrls, routeService })=>(tree, fi
|
|
|
348
343
|
(0, __WEBPACK_EXTERNAL_MODULE_unist_util_visit_555e002a__.visit)(tree, (node)=>{
|
|
349
344
|
if ('mdxJsxFlowElement' !== node.type && 'mdxJsxTextElement' !== node.type || 'img' !== node.name) return;
|
|
350
345
|
const srcAttr = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__.getNodeAttribute)(node, 'src', true);
|
|
351
|
-
if ('string' != typeof
|
|
346
|
+
if ('string' != typeof srcAttr?.value) return;
|
|
352
347
|
const imagePath = normalizeImageUrl(srcAttr.value);
|
|
353
348
|
if (!imagePath) return;
|
|
354
349
|
const tempVariableName = `image${images.length}`;
|
|
@@ -366,22 +361,10 @@ const parseToc = (tree)=>{
|
|
|
366
361
|
if (node.depth >= 1 && node.depth < 5) {
|
|
367
362
|
let customId = '';
|
|
368
363
|
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
|
-
}
|
|
364
|
+
if ('link' === child.type) return child.children?.map((item)=>item.value).join('');
|
|
365
|
+
if ('strong' === child.type) return `**${child.children?.map((item)=>item.value).join('')}**`;
|
|
366
|
+
if ('emphasis' === child.type) return `*${child.children?.map((item)=>item.value).join('')}*`;
|
|
367
|
+
if ('delete' === child.type) return `~~${child.children?.map((item)=>item.value).join('')}~~`;
|
|
385
368
|
if ('text' === child.type) {
|
|
386
369
|
const [textPart, idPart] = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__.extractTextAndId)(child.value);
|
|
387
370
|
customId = idPart;
|
|
@@ -417,23 +400,13 @@ const remarkPluginToc = function() {
|
|
|
417
400
|
};
|
|
418
401
|
};
|
|
419
402
|
async function createMDXOptions(docDirectory, config, checkDeadLinks, routeService, filepath, pluginDriver) {
|
|
420
|
-
|
|
421
|
-
const
|
|
422
|
-
const { remarkPlugins: remarkPluginsFromConfig = [], rehypePlugins: rehypePluginsFromConfig = [], globalComponents: globalComponentsFromConfig = [] } = (null == config ? void 0 : config.markdown) || {};
|
|
403
|
+
const cleanUrls = config?.route?.cleanUrls ?? false;
|
|
404
|
+
const { remarkPlugins: remarkPluginsFromConfig = [], rehypePlugins: rehypePluginsFromConfig = [], globalComponents: globalComponentsFromConfig = [] } = config?.markdown || {};
|
|
423
405
|
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
|
-
});
|
|
406
|
+
const remarkPluginsFromPlugins = rspressPlugins.flatMap((plugin)=>plugin.markdown?.remarkPlugins || []);
|
|
407
|
+
const rehypePluginsFromPlugins = rspressPlugins.flatMap((plugin)=>plugin.markdown?.rehypePlugins || []);
|
|
432
408
|
const globalComponents = [
|
|
433
|
-
...rspressPlugins.flatMap((plugin)=>
|
|
434
|
-
var _plugin_markdown;
|
|
435
|
-
return (null == (_plugin_markdown = plugin.markdown) ? void 0 : _plugin_markdown.globalComponents) || [];
|
|
436
|
-
}),
|
|
409
|
+
...rspressPlugins.flatMap((plugin)=>plugin.markdown?.globalComponents || []),
|
|
437
410
|
...globalComponentsFromConfig
|
|
438
411
|
];
|
|
439
412
|
return {
|
|
@@ -454,7 +427,7 @@ async function createMDXOptions(docDirectory, config, checkDeadLinks, routeServi
|
|
|
454
427
|
remarkCheckDeadLinks,
|
|
455
428
|
{
|
|
456
429
|
root: docDirectory,
|
|
457
|
-
base:
|
|
430
|
+
base: config?.base || '',
|
|
458
431
|
routeService
|
|
459
432
|
}
|
|
460
433
|
],
|
|
@@ -509,7 +482,6 @@ function createCheckPageMetaUpdateFn() {
|
|
|
509
482
|
}
|
|
510
483
|
const checkPageMetaUpdate = createCheckPageMetaUpdateFn();
|
|
511
484
|
async function mdxLoader(source) {
|
|
512
|
-
var _config_markdown;
|
|
513
485
|
this.cacheable(true);
|
|
514
486
|
const callback = this.async();
|
|
515
487
|
const options = this.getOptions();
|
|
@@ -521,55 +493,32 @@ async function mdxLoader(source) {
|
|
|
521
493
|
deps.forEach((dep)=>this.addDependency(dep));
|
|
522
494
|
const replacedContent = applyReplaceRules(flattenContent, config.replaceRules);
|
|
523
495
|
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;
|
|
527
496
|
try {
|
|
528
|
-
let compileResult;
|
|
529
497
|
let pageMeta = {
|
|
530
498
|
title: '',
|
|
531
499
|
toc: [],
|
|
532
500
|
headingTitle: ''
|
|
533
501
|
};
|
|
534
502
|
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
|
-
}
|
|
503
|
+
const mdxOptions = await createMDXOptions(docDirectory, config, checkDeadLinks, routeService, filepath, pluginDriver);
|
|
504
|
+
const compiler = (0, __WEBPACK_EXTERNAL_MODULE__mdx_js_mdx_b904bd09__.createProcessor)(mdxOptions);
|
|
505
|
+
compiler.data('pageMeta', {
|
|
506
|
+
toc: [],
|
|
507
|
+
title: ''
|
|
508
|
+
});
|
|
509
|
+
const vFile = await compiler.process({
|
|
510
|
+
value: preprocessedContent,
|
|
511
|
+
path: filepath
|
|
512
|
+
});
|
|
513
|
+
const compileResult = String(vFile);
|
|
514
|
+
const compilationMeta = compiler.data('pageMeta');
|
|
515
|
+
const headingTitle = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_node_utils_78947ce6__.extractTextAndId)(compilationMeta.title)[0];
|
|
516
|
+
pageMeta = {
|
|
517
|
+
...compilationMeta,
|
|
518
|
+
title: frontmatterTitle || headingTitle,
|
|
519
|
+
headingTitle,
|
|
520
|
+
frontmatter
|
|
521
|
+
};
|
|
573
522
|
if (!(0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.isProduction)()) checkPageMetaUpdate(filepath, pageMeta);
|
|
574
523
|
const result = `const frontmatter = ${JSON.stringify(frontmatter)};
|
|
575
524
|
${compileResult}
|
package/dist/runtime/App.js
CHANGED
|
@@ -13,7 +13,7 @@ function App({ helmetContext }) {
|
|
|
13
13
|
async function refetchData() {
|
|
14
14
|
try {
|
|
15
15
|
const pageData = await (0, __WEBPACK_EXTERNAL_MODULE__initPageData_js_731596b5__.initPageData)(pathname);
|
|
16
|
-
|
|
16
|
+
setPageData?.(pageData);
|
|
17
17
|
} catch (e) {
|
|
18
18
|
console.log(e);
|
|
19
19
|
}
|
|
@@ -3,16 +3,14 @@ import * as __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__ from "@rspress/
|
|
|
3
3
|
import "virtual-global-styles";
|
|
4
4
|
import * as __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__ from "virtual-site-data";
|
|
5
5
|
async function initPageData(routePath) {
|
|
6
|
-
var _siteData_multiVersion;
|
|
7
6
|
const matchedRoute = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.pathnameToRouteService)(routePath);
|
|
8
7
|
if (matchedRoute) {
|
|
9
|
-
var _mod_default___RSPRESS_PAGE_META;
|
|
10
8
|
const mod = await matchedRoute.preload();
|
|
11
9
|
const pagePath = (0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.cleanUrl)(matchedRoute.filePath);
|
|
12
10
|
const normalize = (p)=>p.replace(/\/$/, '').toLowerCase();
|
|
13
11
|
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
12
|
const encodedPagePath = encodeURIComponent(pagePath);
|
|
15
|
-
const meta =
|
|
13
|
+
const meta = mod.default.__RSPRESS_PAGE_META?.[encodedPagePath] || {};
|
|
16
14
|
const { toc = [], title = '', frontmatter = {}, ...rest } = __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.MDX_OR_MD_REGEXP.test(matchedRoute.filePath) ? meta : mod;
|
|
17
15
|
return {
|
|
18
16
|
siteData: __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"],
|
|
@@ -20,7 +18,7 @@ async function initPageData(routePath) {
|
|
|
20
18
|
...rest,
|
|
21
19
|
pagePath,
|
|
22
20
|
...extractPageInfo,
|
|
23
|
-
pageType:
|
|
21
|
+
pageType: frontmatter?.pageType || 'doc',
|
|
24
22
|
title,
|
|
25
23
|
frontmatter,
|
|
26
24
|
toc
|
|
@@ -28,7 +26,7 @@ async function initPageData(routePath) {
|
|
|
28
26
|
};
|
|
29
27
|
}
|
|
30
28
|
let lang = __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].lang || '';
|
|
31
|
-
let version =
|
|
29
|
+
let version = __WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].multiVersion?.default || '';
|
|
32
30
|
if (__WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].lang && 'undefined' != typeof window) {
|
|
33
31
|
const path = location.pathname.replace(__WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].base, '').split('/').slice(0, 2);
|
|
34
32
|
if (__WEBPACK_EXTERNAL_MODULE_virtual_site_data_fa42d4c0__["default"].locales.length) {
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspress/core",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.1",
|
|
4
4
|
"description": "The Rspress Documentation Framework",
|
|
5
5
|
"bugs": "https://github.com/web-infra-dev/rspress/issues",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "https://github.com/web-infra-dev/rspress",
|
|
8
|
+
"url": "git+https://github.com/web-infra-dev/rspress.git",
|
|
9
9
|
"directory": "packages/cli/core"
|
|
10
10
|
},
|
|
11
11
|
"license": "MIT",
|
|
@@ -53,7 +53,6 @@
|
|
|
53
53
|
"hast-util-from-html": "^2.0.3",
|
|
54
54
|
"hast-util-heading-rank": "^3.0.0",
|
|
55
55
|
"html-to-text": "^9.0.5",
|
|
56
|
-
"htmr": "^1.0.2",
|
|
57
56
|
"lodash-es": "^4.17.21",
|
|
58
57
|
"mdast-util-mdxjs-esm": "^2.0.1",
|
|
59
58
|
"picocolors": "^1.1.1",
|
|
@@ -61,6 +60,7 @@
|
|
|
61
60
|
"react-dom": "^19.1.0",
|
|
62
61
|
"react-helmet-async": "^2.0.5",
|
|
63
62
|
"react-lazy-with-preload": "^2.2.1",
|
|
63
|
+
"react-router-dom": "^6.29.0",
|
|
64
64
|
"react-syntax-highlighter": "^15.6.1",
|
|
65
65
|
"rehype-external-links": "^3.0.0",
|
|
66
66
|
"remark": "^15.0.1",
|
|
@@ -70,13 +70,13 @@
|
|
|
70
70
|
"unified": "^11.0.5",
|
|
71
71
|
"unist-util-visit": "^5.0.0",
|
|
72
72
|
"unist-util-visit-children": "^3.0.0",
|
|
73
|
-
"@rspress/plugin-auto-nav-sidebar": "2.0.0-beta.
|
|
74
|
-
"@rspress/plugin-
|
|
75
|
-
"@rspress/plugin-
|
|
76
|
-
"@rspress/plugin-medium-zoom": "2.0.0-beta.
|
|
77
|
-
"@rspress/
|
|
78
|
-
"@rspress/
|
|
79
|
-
"@rspress/
|
|
73
|
+
"@rspress/plugin-auto-nav-sidebar": "2.0.0-beta.1",
|
|
74
|
+
"@rspress/plugin-container-syntax": "2.0.0-beta.1",
|
|
75
|
+
"@rspress/plugin-last-updated": "2.0.0-beta.1",
|
|
76
|
+
"@rspress/plugin-medium-zoom": "2.0.0-beta.1",
|
|
77
|
+
"@rspress/theme-default": "2.0.0-beta.1",
|
|
78
|
+
"@rspress/shared": "2.0.0-beta.1",
|
|
79
|
+
"@rspress/runtime": "2.0.0-beta.1"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
82
|
"@microsoft/api-extractor": "^7.52.4",
|
|
@@ -98,14 +98,15 @@
|
|
|
98
98
|
"remark-rehype": "^11.1.2",
|
|
99
99
|
"remark-stringify": "^11.0.0",
|
|
100
100
|
"rimraf": "^6.0.1",
|
|
101
|
+
"rsbuild-plugin-publint": "^0.3.0",
|
|
101
102
|
"rsbuild-plugin-virtual-module": "0.1.1",
|
|
102
103
|
"tailwindcss": "^3.4.17",
|
|
103
104
|
"typescript": "^5.8.2",
|
|
104
|
-
"vfile": "^
|
|
105
|
+
"vfile": "^6.0.3",
|
|
105
106
|
"@rspress/config": "1.0.0"
|
|
106
107
|
},
|
|
107
108
|
"engines": {
|
|
108
|
-
"node": ">=
|
|
109
|
+
"node": ">=18.0.0"
|
|
109
110
|
},
|
|
110
111
|
"publishConfig": {
|
|
111
112
|
"access": "public",
|