@rspress/shared 1.43.13 → 1.45.0
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/constants.js +12 -8
- package/dist/index.d.ts +1 -1
- package/dist/index.js +90 -32
- package/dist/index.mjs +2 -4
- package/dist/logger.js +8 -8
- package/dist/node-utils.d.ts +14 -1
- package/dist/node-utils.js +39 -20
- package/dist/node-utils.mjs +15 -3
- package/package.json +3 -3
package/dist/constants.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
var __webpack_require__ = {};
|
3
3
|
(()=>{
|
4
|
-
__webpack_require__.d =
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
5
5
|
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
6
6
|
enumerable: true,
|
7
7
|
get: definition[key]
|
@@ -9,12 +9,10 @@ var __webpack_require__ = {};
|
|
9
9
|
};
|
10
10
|
})();
|
11
11
|
(()=>{
|
12
|
-
__webpack_require__.o =
|
13
|
-
return Object.prototype.hasOwnProperty.call(obj, prop);
|
14
|
-
};
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
15
13
|
})();
|
16
14
|
(()=>{
|
17
|
-
__webpack_require__.r =
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
18
16
|
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
19
17
|
value: 'Module'
|
20
18
|
});
|
@@ -47,8 +45,14 @@ const DEFAULT_PAGE_EXTENSIONS = [
|
|
47
45
|
'.md',
|
48
46
|
'.mdx'
|
49
47
|
];
|
50
|
-
|
51
|
-
|
52
|
-
|
48
|
+
exports.DEFAULT_CONFIG_EXTENSIONS = __webpack_exports__.DEFAULT_CONFIG_EXTENSIONS;
|
49
|
+
exports.DEFAULT_CONFIG_NAME = __webpack_exports__.DEFAULT_CONFIG_NAME;
|
50
|
+
exports.DEFAULT_PAGE_EXTENSIONS = __webpack_exports__.DEFAULT_PAGE_EXTENSIONS;
|
51
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
52
|
+
"DEFAULT_CONFIG_EXTENSIONS",
|
53
|
+
"DEFAULT_CONFIG_NAME",
|
54
|
+
"DEFAULT_PAGE_EXTENSIONS"
|
55
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
56
|
+
Object.defineProperty(exports, '__esModule', {
|
53
57
|
value: true
|
54
58
|
});
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
var __webpack_require__ = {};
|
3
3
|
(()=>{
|
4
|
-
__webpack_require__.d =
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
5
5
|
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
6
6
|
enumerable: true,
|
7
7
|
get: definition[key]
|
@@ -9,12 +9,10 @@ var __webpack_require__ = {};
|
|
9
9
|
};
|
10
10
|
})();
|
11
11
|
(()=>{
|
12
|
-
__webpack_require__.o =
|
13
|
-
return Object.prototype.hasOwnProperty.call(obj, prop);
|
14
|
-
};
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
15
13
|
})();
|
16
14
|
(()=>{
|
17
|
-
__webpack_require__.r =
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
18
16
|
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
19
17
|
value: 'Module'
|
20
18
|
});
|
@@ -26,37 +24,37 @@ var __webpack_require__ = {};
|
|
26
24
|
var __webpack_exports__ = {};
|
27
25
|
__webpack_require__.r(__webpack_exports__);
|
28
26
|
__webpack_require__.d(__webpack_exports__, {
|
29
|
-
SEARCH_INDEX_NAME: ()=>SEARCH_INDEX_NAME,
|
30
27
|
RSPRESS_TEMP_DIR: ()=>RSPRESS_TEMP_DIR,
|
31
|
-
|
32
|
-
|
33
|
-
addTrailingSlash: ()=>addTrailingSlash,
|
28
|
+
parseUrl: ()=>parseUrl,
|
29
|
+
withBase: ()=>withBase,
|
34
30
|
slash: ()=>slash,
|
31
|
+
removeBase: ()=>removeBase,
|
32
|
+
replaceLang: ()=>replaceLang,
|
35
33
|
removeLeadingSlash: ()=>removeLeadingSlash,
|
36
|
-
|
34
|
+
addLeadingSlash: ()=>addLeadingSlash,
|
37
35
|
replaceVersion: ()=>replaceVersion,
|
36
|
+
isDevDebugMode: ()=>isDevDebugMode,
|
38
37
|
HASH_REGEXP: ()=>HASH_REGEXP,
|
39
|
-
|
38
|
+
withoutLang: ()=>withoutLang,
|
40
39
|
MDX_OR_MD_REGEXP: ()=>MDX_OR_MD_REGEXP,
|
41
|
-
|
40
|
+
SEARCH_INDEX_NAME: ()=>SEARCH_INDEX_NAME,
|
41
|
+
withoutBase: ()=>withoutBase,
|
42
|
+
isDebugMode: ()=>isDebugMode,
|
43
|
+
isExternalUrl: ()=>isExternalUrl,
|
44
|
+
isSCM: ()=>isSCM,
|
45
|
+
addTrailingSlash: ()=>addTrailingSlash,
|
42
46
|
normalizeSlash: ()=>normalizeSlash,
|
47
|
+
APPEARANCE_KEY: ()=>APPEARANCE_KEY,
|
48
|
+
normalizeHref: ()=>normalizeHref,
|
43
49
|
normalizePosixPath: ()=>normalizePosixPath,
|
44
|
-
inBrowser: ()=>inBrowser,
|
45
|
-
isDataUrl: ()=>isDataUrl,
|
46
|
-
replaceLang: ()=>replaceLang,
|
47
50
|
removeHash: ()=>removeHash,
|
48
|
-
cleanUrl: ()=>runtime_utils_cleanUrl,
|
49
|
-
withBase: ()=>withBase,
|
50
|
-
isDevDebugMode: ()=>isDevDebugMode,
|
51
51
|
removeTrailingSlash: ()=>removeTrailingSlash,
|
52
|
-
|
53
|
-
isExternalUrl: ()=>isExternalUrl,
|
54
|
-
removeBase: ()=>removeBase,
|
55
|
-
DEFAULT_HIGHLIGHT_LANGUAGES: ()=>DEFAULT_HIGHLIGHT_LANGUAGES,
|
56
|
-
parseUrl: ()=>parseUrl,
|
57
|
-
withoutLang: ()=>withoutLang,
|
52
|
+
QUERY_REGEXP: ()=>QUERY_REGEXP,
|
58
53
|
isProduction: ()=>isProduction,
|
59
|
-
|
54
|
+
DEFAULT_HIGHLIGHT_LANGUAGES: ()=>DEFAULT_HIGHLIGHT_LANGUAGES,
|
55
|
+
inBrowser: ()=>inBrowser,
|
56
|
+
isDataUrl: ()=>isDataUrl,
|
57
|
+
cleanUrl: ()=>runtime_utils_cleanUrl
|
60
58
|
});
|
61
59
|
const QUERY_REGEXP = /\?.*$/s;
|
62
60
|
const HASH_REGEXP = /#.*$/s;
|
@@ -193,10 +191,8 @@ function normalizeHref(url, cleanUrls = false) {
|
|
193
191
|
if (!url) return '/';
|
194
192
|
if (isExternalUrl(url)) return url;
|
195
193
|
let { url: cleanUrl, hash } = parseUrl(decodeURIComponent(url));
|
196
|
-
if (!cleanUrls && !cleanUrl.endsWith('.html'))
|
197
|
-
|
198
|
-
else cleanUrl += '.html';
|
199
|
-
}
|
194
|
+
if (!cleanUrls && !cleanUrl.endsWith('.html')) if (cleanUrl.endsWith('/')) cleanUrl += 'index.html';
|
195
|
+
else cleanUrl += '.html';
|
200
196
|
if (cleanUrls && cleanUrl.endsWith('/')) cleanUrl += 'index';
|
201
197
|
if (cleanUrls && cleanUrl.endsWith('.html')) cleanUrl = cleanUrl.replace(/\.html$/, '');
|
202
198
|
return addLeadingSlash(hash ? `${cleanUrl}#${hash}` : cleanUrl);
|
@@ -216,8 +212,70 @@ function withBase(url, base) {
|
|
216
212
|
function removeBase(url, base) {
|
217
213
|
return addLeadingSlash(url).replace(new RegExp(`^${normalizeSlash(base)}`), '');
|
218
214
|
}
|
219
|
-
|
220
|
-
|
221
|
-
|
215
|
+
exports.APPEARANCE_KEY = __webpack_exports__.APPEARANCE_KEY;
|
216
|
+
exports.DEFAULT_HIGHLIGHT_LANGUAGES = __webpack_exports__.DEFAULT_HIGHLIGHT_LANGUAGES;
|
217
|
+
exports.HASH_REGEXP = __webpack_exports__.HASH_REGEXP;
|
218
|
+
exports.MDX_OR_MD_REGEXP = __webpack_exports__.MDX_OR_MD_REGEXP;
|
219
|
+
exports.QUERY_REGEXP = __webpack_exports__.QUERY_REGEXP;
|
220
|
+
exports.RSPRESS_TEMP_DIR = __webpack_exports__.RSPRESS_TEMP_DIR;
|
221
|
+
exports.SEARCH_INDEX_NAME = __webpack_exports__.SEARCH_INDEX_NAME;
|
222
|
+
exports.addLeadingSlash = __webpack_exports__.addLeadingSlash;
|
223
|
+
exports.addTrailingSlash = __webpack_exports__.addTrailingSlash;
|
224
|
+
exports.cleanUrl = __webpack_exports__.cleanUrl;
|
225
|
+
exports.inBrowser = __webpack_exports__.inBrowser;
|
226
|
+
exports.isDataUrl = __webpack_exports__.isDataUrl;
|
227
|
+
exports.isDebugMode = __webpack_exports__.isDebugMode;
|
228
|
+
exports.isDevDebugMode = __webpack_exports__.isDevDebugMode;
|
229
|
+
exports.isExternalUrl = __webpack_exports__.isExternalUrl;
|
230
|
+
exports.isProduction = __webpack_exports__.isProduction;
|
231
|
+
exports.isSCM = __webpack_exports__.isSCM;
|
232
|
+
exports.normalizeHref = __webpack_exports__.normalizeHref;
|
233
|
+
exports.normalizePosixPath = __webpack_exports__.normalizePosixPath;
|
234
|
+
exports.normalizeSlash = __webpack_exports__.normalizeSlash;
|
235
|
+
exports.parseUrl = __webpack_exports__.parseUrl;
|
236
|
+
exports.removeBase = __webpack_exports__.removeBase;
|
237
|
+
exports.removeHash = __webpack_exports__.removeHash;
|
238
|
+
exports.removeLeadingSlash = __webpack_exports__.removeLeadingSlash;
|
239
|
+
exports.removeTrailingSlash = __webpack_exports__.removeTrailingSlash;
|
240
|
+
exports.replaceLang = __webpack_exports__.replaceLang;
|
241
|
+
exports.replaceVersion = __webpack_exports__.replaceVersion;
|
242
|
+
exports.slash = __webpack_exports__.slash;
|
243
|
+
exports.withBase = __webpack_exports__.withBase;
|
244
|
+
exports.withoutBase = __webpack_exports__.withoutBase;
|
245
|
+
exports.withoutLang = __webpack_exports__.withoutLang;
|
246
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
247
|
+
"APPEARANCE_KEY",
|
248
|
+
"DEFAULT_HIGHLIGHT_LANGUAGES",
|
249
|
+
"HASH_REGEXP",
|
250
|
+
"MDX_OR_MD_REGEXP",
|
251
|
+
"QUERY_REGEXP",
|
252
|
+
"RSPRESS_TEMP_DIR",
|
253
|
+
"SEARCH_INDEX_NAME",
|
254
|
+
"addLeadingSlash",
|
255
|
+
"addTrailingSlash",
|
256
|
+
"cleanUrl",
|
257
|
+
"inBrowser",
|
258
|
+
"isDataUrl",
|
259
|
+
"isDebugMode",
|
260
|
+
"isDevDebugMode",
|
261
|
+
"isExternalUrl",
|
262
|
+
"isProduction",
|
263
|
+
"isSCM",
|
264
|
+
"normalizeHref",
|
265
|
+
"normalizePosixPath",
|
266
|
+
"normalizeSlash",
|
267
|
+
"parseUrl",
|
268
|
+
"removeBase",
|
269
|
+
"removeHash",
|
270
|
+
"removeLeadingSlash",
|
271
|
+
"removeTrailingSlash",
|
272
|
+
"replaceLang",
|
273
|
+
"replaceVersion",
|
274
|
+
"slash",
|
275
|
+
"withBase",
|
276
|
+
"withoutBase",
|
277
|
+
"withoutLang"
|
278
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
279
|
+
Object.defineProperty(exports, '__esModule', {
|
222
280
|
value: true
|
223
281
|
});
|
package/dist/index.mjs
CHANGED
@@ -133,10 +133,8 @@ function normalizeHref(url, cleanUrls = false) {
|
|
133
133
|
if (!url) return '/';
|
134
134
|
if (isExternalUrl(url)) return url;
|
135
135
|
let { url: cleanUrl, hash } = parseUrl(decodeURIComponent(url));
|
136
|
-
if (!cleanUrls && !cleanUrl.endsWith('.html'))
|
137
|
-
|
138
|
-
else cleanUrl += '.html';
|
139
|
-
}
|
136
|
+
if (!cleanUrls && !cleanUrl.endsWith('.html')) if (cleanUrl.endsWith('/')) cleanUrl += 'index.html';
|
137
|
+
else cleanUrl += '.html';
|
140
138
|
if (cleanUrls && cleanUrl.endsWith('/')) cleanUrl += 'index';
|
141
139
|
if (cleanUrls && cleanUrl.endsWith('.html')) cleanUrl = cleanUrl.replace(/\.html$/, '');
|
142
140
|
return addLeadingSlash(hash ? `${cleanUrl}#${hash}` : cleanUrl);
|
package/dist/logger.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
var __webpack_require__ = {};
|
3
3
|
(()=>{
|
4
|
-
__webpack_require__.d =
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
5
5
|
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
6
6
|
enumerable: true,
|
7
7
|
get: definition[key]
|
@@ -9,12 +9,10 @@ var __webpack_require__ = {};
|
|
9
9
|
};
|
10
10
|
})();
|
11
11
|
(()=>{
|
12
|
-
__webpack_require__.o =
|
13
|
-
return Object.prototype.hasOwnProperty.call(obj, prop);
|
14
|
-
};
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
15
13
|
})();
|
16
14
|
(()=>{
|
17
|
-
__webpack_require__.r =
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
18
16
|
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
19
17
|
value: 'Module'
|
20
18
|
});
|
@@ -29,8 +27,10 @@ __webpack_require__.d(__webpack_exports__, {
|
|
29
27
|
logger: ()=>core_namespaceObject.logger
|
30
28
|
});
|
31
29
|
const core_namespaceObject = require("@rsbuild/core");
|
32
|
-
|
33
|
-
for(var __webpack_i__ in __webpack_exports__)
|
34
|
-
|
30
|
+
exports.logger = __webpack_exports__.logger;
|
31
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
32
|
+
"logger"
|
33
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
34
|
+
Object.defineProperty(exports, '__esModule', {
|
35
35
|
value: true
|
36
36
|
});
|
package/dist/node-utils.d.ts
CHANGED
@@ -207,6 +207,18 @@ declare interface FrontMatterMeta {
|
|
207
207
|
[key: string]: unknown;
|
208
208
|
}
|
209
209
|
|
210
|
+
/**
|
211
|
+
* Transform `config.icon` into final url path in the web app
|
212
|
+
*
|
213
|
+
* @param icon original icon in config
|
214
|
+
* @returns final url path in the web app
|
215
|
+
*/
|
216
|
+
export declare function getIconUrlPath(icon: '' | undefined): undefined;
|
217
|
+
|
218
|
+
export declare function getIconUrlPath(icon: string | URL): string;
|
219
|
+
|
220
|
+
export declare function getIconUrlPath(icon: string | URL | undefined): string | undefined;
|
221
|
+
|
210
222
|
export declare function getNodeAttribute(node: MdxJsxFlowElement | MdxJsxTextElement, attrName: string, attribute?: false): string | MdxJsxAttributeValueExpression | null | undefined;
|
211
223
|
|
212
224
|
export declare function getNodeAttribute(node: MdxJsxFlowElement | MdxJsxTextElement, attrName: string, attribute: true): MdxJsxAttribute | MdxJsxExpressionAttribute | undefined;
|
@@ -245,6 +257,7 @@ declare interface Hero {
|
|
245
257
|
export declare function loadFrontMatter<TFrontmatter extends Record<string, unknown> = FrontMatterMeta>(source: string, filepath: string, root: string, outputWarning?: boolean): {
|
246
258
|
frontmatter: TFrontmatter;
|
247
259
|
content: string;
|
260
|
+
emptyLinesSource: string;
|
248
261
|
};
|
249
262
|
|
250
263
|
declare interface Locale {
|
@@ -600,7 +613,7 @@ declare interface UserConfig<ThemeConfig = Config> {
|
|
600
613
|
/**
|
601
614
|
* Path to html icon file.
|
602
615
|
*/
|
603
|
-
icon?: string;
|
616
|
+
icon?: string | URL;
|
604
617
|
/**
|
605
618
|
* Default language of the site.
|
606
619
|
*/
|
package/dist/node-utils.js
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
var __webpack_modules__ = {
|
3
3
|
"lodash-es": function(module) {
|
4
|
-
module.exports = import("lodash-es")
|
4
|
+
module.exports = import("lodash-es").then(function(module) {
|
5
|
+
return module;
|
6
|
+
});
|
5
7
|
}
|
6
8
|
};
|
7
9
|
var __webpack_module_cache__ = {};
|
@@ -15,12 +17,8 @@ function __webpack_require__(moduleId) {
|
|
15
17
|
return module.exports;
|
16
18
|
}
|
17
19
|
(()=>{
|
18
|
-
__webpack_require__.n =
|
19
|
-
var getter = module && module.__esModule ?
|
20
|
-
return module['default'];
|
21
|
-
} : function() {
|
22
|
-
return module;
|
23
|
-
};
|
20
|
+
__webpack_require__.n = (module)=>{
|
21
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
24
22
|
__webpack_require__.d(getter, {
|
25
23
|
a: getter
|
26
24
|
});
|
@@ -28,7 +26,7 @@ function __webpack_require__(moduleId) {
|
|
28
26
|
};
|
29
27
|
})();
|
30
28
|
(()=>{
|
31
|
-
__webpack_require__.d =
|
29
|
+
__webpack_require__.d = (exports1, definition)=>{
|
32
30
|
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
33
31
|
enumerable: true,
|
34
32
|
get: definition[key]
|
@@ -36,12 +34,10 @@ function __webpack_require__(moduleId) {
|
|
36
34
|
};
|
37
35
|
})();
|
38
36
|
(()=>{
|
39
|
-
__webpack_require__.o =
|
40
|
-
return Object.prototype.hasOwnProperty.call(obj, prop);
|
41
|
-
};
|
37
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
42
38
|
})();
|
43
39
|
(()=>{
|
44
|
-
__webpack_require__.r =
|
40
|
+
__webpack_require__.r = (exports1)=>{
|
45
41
|
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
46
42
|
value: 'Module'
|
47
43
|
});
|
@@ -56,8 +52,9 @@ var __webpack_exports__ = {};
|
|
56
52
|
__webpack_require__.d(__webpack_exports__, {
|
57
53
|
extractTextAndId: ()=>extractTextAndId,
|
58
54
|
loadFrontMatter: ()=>loadFrontMatter,
|
55
|
+
mergeDocConfig: ()=>mergeDocConfig,
|
59
56
|
getNodeAttribute: ()=>getNodeAttribute,
|
60
|
-
|
57
|
+
getIconUrlPath: ()=>getIconUrlPath
|
61
58
|
});
|
62
59
|
const extractTextAndId = (title)=>{
|
63
60
|
if (!title) return [
|
@@ -72,28 +69,40 @@ var __webpack_exports__ = {};
|
|
72
69
|
customId
|
73
70
|
];
|
74
71
|
};
|
72
|
+
const external_node_path_namespaceObject = require("node:path");
|
73
|
+
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
74
|
+
const external_node_url_namespaceObject = require("node:url");
|
75
|
+
function getIconUrlPath(icon) {
|
76
|
+
if (!icon) return;
|
77
|
+
icon = icon.toString();
|
78
|
+
if (icon.startsWith('file://')) icon = (0, external_node_url_namespaceObject.fileURLToPath)(icon);
|
79
|
+
if (!external_node_path_default().isAbsolute(icon)) return icon;
|
80
|
+
return `/${external_node_path_default().basename(icon)}`;
|
81
|
+
}
|
75
82
|
function getNodeAttribute(node, attrName, attribute) {
|
76
83
|
const found = node.attributes.find((attr)=>'name' in attr && attr.name === attrName);
|
77
84
|
return attribute ? found : found?.value;
|
78
85
|
}
|
79
|
-
const external_node_path_namespaceObject = require("node:path");
|
80
|
-
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
81
86
|
const external_gray_matter_namespaceObject = require("gray-matter");
|
82
87
|
var external_gray_matter_default = /*#__PURE__*/ __webpack_require__.n(external_gray_matter_namespaceObject);
|
83
88
|
const core_namespaceObject = require("@rsbuild/core");
|
84
89
|
function loadFrontMatter(source, filepath, root, outputWarning = false) {
|
85
90
|
try {
|
86
91
|
const { content, data } = external_gray_matter_default()(source);
|
92
|
+
const rawFrontMatter = source.slice(0, source.length - content.length);
|
93
|
+
const emptyLinesSource = rawFrontMatter.length ? `${rawFrontMatter.replace(/[^\n]/g, '')}${content}` : content;
|
87
94
|
return {
|
88
95
|
content,
|
89
|
-
frontmatter: data
|
96
|
+
frontmatter: data,
|
97
|
+
emptyLinesSource
|
90
98
|
};
|
91
99
|
} catch (e) {
|
92
100
|
if (outputWarning) core_namespaceObject.logger.warn(`Parse frontmatter error in ${external_node_path_default().relative(root, filepath)}: \n`, e);
|
93
101
|
}
|
94
102
|
return {
|
95
103
|
content: '',
|
96
|
-
frontmatter: {}
|
104
|
+
frontmatter: {},
|
105
|
+
emptyLinesSource: source
|
97
106
|
};
|
98
107
|
}
|
99
108
|
const castArray = (value)=>Array.isArray(value) ? value : [
|
@@ -114,8 +123,18 @@ var __webpack_exports__ = {};
|
|
114
123
|
});
|
115
124
|
};
|
116
125
|
})();
|
117
|
-
|
118
|
-
|
119
|
-
|
126
|
+
exports.extractTextAndId = __webpack_exports__.extractTextAndId;
|
127
|
+
exports.getIconUrlPath = __webpack_exports__.getIconUrlPath;
|
128
|
+
exports.getNodeAttribute = __webpack_exports__.getNodeAttribute;
|
129
|
+
exports.loadFrontMatter = __webpack_exports__.loadFrontMatter;
|
130
|
+
exports.mergeDocConfig = __webpack_exports__.mergeDocConfig;
|
131
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
132
|
+
"extractTextAndId",
|
133
|
+
"getIconUrlPath",
|
134
|
+
"getNodeAttribute",
|
135
|
+
"loadFrontMatter",
|
136
|
+
"mergeDocConfig"
|
137
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
138
|
+
Object.defineProperty(exports, '__esModule', {
|
120
139
|
value: true
|
121
140
|
});
|
package/dist/node-utils.mjs
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__ from "node:url";
|
2
3
|
import * as __WEBPACK_EXTERNAL_MODULE_gray_matter_90c6cd0b__ from "gray-matter";
|
3
4
|
import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__ from "@rsbuild/core";
|
4
5
|
const extractTextAndId = (title)=>{
|
@@ -14,6 +15,13 @@ const extractTextAndId = (title)=>{
|
|
14
15
|
customId
|
15
16
|
];
|
16
17
|
};
|
18
|
+
function getIconUrlPath(icon) {
|
19
|
+
if (!icon) return;
|
20
|
+
icon = icon.toString();
|
21
|
+
if (icon.startsWith('file://')) icon = (0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.fileURLToPath)(icon);
|
22
|
+
if (!__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].isAbsolute(icon)) return icon;
|
23
|
+
return `/${__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].basename(icon)}`;
|
24
|
+
}
|
17
25
|
function getNodeAttribute(node, attrName, attribute) {
|
18
26
|
const found = node.attributes.find((attr)=>'name' in attr && attr.name === attrName);
|
19
27
|
return attribute ? found : found?.value;
|
@@ -21,16 +29,20 @@ function getNodeAttribute(node, attrName, attribute) {
|
|
21
29
|
function loadFrontMatter(source, filepath, root, outputWarning = false) {
|
22
30
|
try {
|
23
31
|
const { content, data } = (0, __WEBPACK_EXTERNAL_MODULE_gray_matter_90c6cd0b__["default"])(source);
|
32
|
+
const rawFrontMatter = source.slice(0, source.length - content.length);
|
33
|
+
const emptyLinesSource = rawFrontMatter.length ? `${rawFrontMatter.replace(/[^\n]/g, '')}${content}` : content;
|
24
34
|
return {
|
25
35
|
content,
|
26
|
-
frontmatter: data
|
36
|
+
frontmatter: data,
|
37
|
+
emptyLinesSource
|
27
38
|
};
|
28
39
|
} catch (e) {
|
29
40
|
if (outputWarning) __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.logger.warn(`Parse frontmatter error in ${__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(root, filepath)}: \n`, e);
|
30
41
|
}
|
31
42
|
return {
|
32
43
|
content: '',
|
33
|
-
frontmatter: {}
|
44
|
+
frontmatter: {},
|
45
|
+
emptyLinesSource: source
|
34
46
|
};
|
35
47
|
}
|
36
48
|
const castArray = (value)=>Array.isArray(value) ? value : [
|
@@ -50,4 +62,4 @@ const mergeDocConfig = async (...configs)=>{
|
|
50
62
|
];
|
51
63
|
});
|
52
64
|
};
|
53
|
-
export { extractTextAndId, getNodeAttribute, loadFrontMatter, mergeDocConfig };
|
65
|
+
export { extractTextAndId, getIconUrlPath, getNodeAttribute, loadFrontMatter, mergeDocConfig };
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@rspress/shared",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.45.0",
|
4
4
|
"repository": {
|
5
5
|
"type": "git",
|
6
6
|
"url": "https://github.com/web-infra-dev/rspress",
|
@@ -36,13 +36,13 @@
|
|
36
36
|
"dist"
|
37
37
|
],
|
38
38
|
"dependencies": {
|
39
|
-
"@rsbuild/core": "1.3.
|
39
|
+
"@rsbuild/core": "~1.3.18",
|
40
40
|
"gray-matter": "4.0.3",
|
41
41
|
"lodash-es": "^4.17.21",
|
42
42
|
"unified": "^10.1.2"
|
43
43
|
},
|
44
44
|
"devDependencies": {
|
45
|
-
"@rslib/core": "0.
|
45
|
+
"@rslib/core": "~0.6.9",
|
46
46
|
"@types/fs-extra": "11.0.4",
|
47
47
|
"@types/jest": "~29.5.14",
|
48
48
|
"@types/lodash-es": "^4.17.12",
|