@rspress/shared 2.0.0-beta.13 → 2.0.0-beta.15
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 +2 -2
- package/dist/node-utils.d.ts +2 -2
- package/dist/node-utils.js +16 -10
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
@@ -449,9 +449,8 @@ export declare interface PageData {
|
|
449
449
|
* and should not be used in the runtime (usePageData).
|
450
450
|
*/
|
451
451
|
export declare interface PageIndexInfo {
|
452
|
-
id: number;
|
453
|
-
title: string;
|
454
452
|
routePath: string;
|
453
|
+
title: string;
|
455
454
|
toc: Header[];
|
456
455
|
content: string;
|
457
456
|
_flattenContent?: string;
|
@@ -626,6 +625,7 @@ declare interface RspressPlugin {
|
|
626
625
|
addPages?: (config: UserConfig, isProd: boolean) => AdditionalPage[] | Promise<AdditionalPage[]>;
|
627
626
|
/**
|
628
627
|
* Add runtime modules
|
628
|
+
* @deprecated use [rsbuild-plugin-virtual-module](https://github.com/rspack-contrib/rsbuild-plugin-virtual-module) instead.
|
629
629
|
*/
|
630
630
|
addRuntimeModules?: (config: UserConfig, isProd: boolean) => Record<string, string> | Promise<Record<string, string>>;
|
631
631
|
/**
|
package/dist/node-utils.d.ts
CHANGED
@@ -376,9 +376,8 @@ declare interface NavItemWithLinkAndChildren {
|
|
376
376
|
* and should not be used in the runtime (usePageData).
|
377
377
|
*/
|
378
378
|
declare interface PageIndexInfo {
|
379
|
-
id: number;
|
380
|
-
title: string;
|
381
379
|
routePath: string;
|
380
|
+
title: string;
|
382
381
|
toc: Header[];
|
383
382
|
content: string;
|
384
383
|
_flattenContent?: string;
|
@@ -493,6 +492,7 @@ declare interface RspressPlugin {
|
|
493
492
|
addPages?: (config: UserConfig, isProd: boolean) => AdditionalPage[] | Promise<AdditionalPage[]>;
|
494
493
|
/**
|
495
494
|
* Add runtime modules
|
495
|
+
* @deprecated use [rsbuild-plugin-virtual-module](https://github.com/rspack-contrib/rsbuild-plugin-virtual-module) instead.
|
496
496
|
*/
|
497
497
|
addRuntimeModules?: (config: UserConfig, isProd: boolean) => Record<string, string> | Promise<Record<string, string>>;
|
498
498
|
/**
|
package/dist/node-utils.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
import
|
1
|
+
import node_path from "node:path";
|
2
2
|
import { fileURLToPath } from "node:url";
|
3
|
-
import
|
3
|
+
import gray_matter from "gray-matter";
|
4
4
|
import { logger } from "@rsbuild/core";
|
5
5
|
const extractTextAndId = (title)=>{
|
6
6
|
if (!title) return [
|
@@ -8,19 +8,25 @@ const extractTextAndId = (title)=>{
|
|
8
8
|
''
|
9
9
|
];
|
10
10
|
const customIdReg = /\\?{#.*}/;
|
11
|
-
|
12
|
-
|
11
|
+
if (customIdReg.test(title)) {
|
12
|
+
const text = title.replace(customIdReg, '').trimEnd();
|
13
|
+
const customId = title.match(customIdReg)?.[0]?.slice(2, -1) || '';
|
14
|
+
return [
|
15
|
+
text,
|
16
|
+
customId
|
17
|
+
];
|
18
|
+
}
|
13
19
|
return [
|
14
|
-
|
15
|
-
|
20
|
+
title,
|
21
|
+
''
|
16
22
|
];
|
17
23
|
};
|
18
24
|
function getIconUrlPath(icon) {
|
19
25
|
if (!icon) return;
|
20
26
|
icon = icon.toString();
|
21
27
|
if (icon.startsWith('file://')) icon = fileURLToPath(icon);
|
22
|
-
if (!
|
23
|
-
return `/${
|
28
|
+
if (!node_path.isAbsolute(icon)) return icon;
|
29
|
+
return `/${node_path.basename(icon)}`;
|
24
30
|
}
|
25
31
|
function getNodeAttribute(node, attrName, attribute) {
|
26
32
|
const found = node.attributes.find((attr)=>'name' in attr && attr.name === attrName);
|
@@ -28,7 +34,7 @@ function getNodeAttribute(node, attrName, attribute) {
|
|
28
34
|
}
|
29
35
|
function loadFrontMatter(source, filepath, root, outputWarning = false) {
|
30
36
|
try {
|
31
|
-
const { content, data } =
|
37
|
+
const { content, data } = gray_matter(source);
|
32
38
|
const rawFrontMatter = source.slice(0, source.length - content.length);
|
33
39
|
const emptyLinesSource = rawFrontMatter.length ? `${rawFrontMatter.replace(/[^\n]/g, '')}${content}` : content;
|
34
40
|
return {
|
@@ -37,7 +43,7 @@ function loadFrontMatter(source, filepath, root, outputWarning = false) {
|
|
37
43
|
emptyLinesSource
|
38
44
|
};
|
39
45
|
} catch (e) {
|
40
|
-
if (outputWarning) logger.warn(`Parse frontmatter error in ${
|
46
|
+
if (outputWarning) logger.warn(`Parse frontmatter error in ${node_path.relative(root, filepath)}: \n`, e);
|
41
47
|
}
|
42
48
|
return {
|
43
49
|
content: '',
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@rspress/shared",
|
3
|
-
"version": "2.0.0-beta.
|
3
|
+
"version": "2.0.0-beta.15",
|
4
4
|
"repository": {
|
5
5
|
"type": "git",
|
6
6
|
"url": "git+https://github.com/web-infra-dev/rspress.git",
|
@@ -39,11 +39,11 @@
|
|
39
39
|
"unified": "^11.0.5"
|
40
40
|
},
|
41
41
|
"devDependencies": {
|
42
|
-
"@rslib/core": "0.
|
42
|
+
"@rslib/core": "0.10.0",
|
43
43
|
"@types/jest": "~29.5.14",
|
44
44
|
"@types/lodash-es": "^4.17.12",
|
45
45
|
"@types/node": "^22.8.1",
|
46
|
-
"@types/react": "^19.1.
|
46
|
+
"@types/react": "^19.1.8",
|
47
47
|
"mdast-util-mdx-jsx": "^3.2.0",
|
48
48
|
"medium-zoom": "1.1.0",
|
49
49
|
"rimraf": "^6.0.1",
|