@rspress/shared 2.0.0-alpha.3 → 2.0.0-alpha.5
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.js +5 -3
- package/dist/index.mjs +5 -3
- package/dist/node-utils.d.ts +6 -2
- package/dist/node-utils.js +4 -1
- package/dist/node-utils.mjs +4 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -190,13 +190,15 @@ const parseUrl = (url)=>{
|
|
190
190
|
function normalizeHref(url, cleanUrls = false) {
|
191
191
|
if (!url) return '/';
|
192
192
|
if (isExternalUrl(url)) return url;
|
193
|
+
if (url.startsWith('#')) return url;
|
193
194
|
let { url: cleanUrl, hash } = parseUrl(decodeURIComponent(url));
|
194
|
-
if (
|
195
|
+
if (cleanUrls) {
|
196
|
+
if (cleanUrl.endsWith('.html')) cleanUrl = cleanUrl.replace(/\.html$/, '');
|
197
|
+
if (cleanUrls && cleanUrl.endsWith('/index')) cleanUrl = cleanUrl.replace(/\/index$/, '/');
|
198
|
+
} else if (!cleanUrl.endsWith('.html')) {
|
195
199
|
if (cleanUrl.endsWith('/')) cleanUrl += 'index.html';
|
196
200
|
else cleanUrl += '.html';
|
197
201
|
}
|
198
|
-
if (cleanUrls && cleanUrl.endsWith('/')) cleanUrl += 'index';
|
199
|
-
if (cleanUrls && cleanUrl.endsWith('.html')) cleanUrl = cleanUrl.replace(/\.html$/, '');
|
200
202
|
return addLeadingSlash(hash ? `${cleanUrl}#${hash}` : cleanUrl);
|
201
203
|
}
|
202
204
|
function withoutLang(path, langs) {
|
package/dist/index.mjs
CHANGED
@@ -132,13 +132,15 @@ const parseUrl = (url)=>{
|
|
132
132
|
function normalizeHref(url, cleanUrls = false) {
|
133
133
|
if (!url) return '/';
|
134
134
|
if (isExternalUrl(url)) return url;
|
135
|
+
if (url.startsWith('#')) return url;
|
135
136
|
let { url: cleanUrl, hash } = parseUrl(decodeURIComponent(url));
|
136
|
-
if (
|
137
|
+
if (cleanUrls) {
|
138
|
+
if (cleanUrl.endsWith('.html')) cleanUrl = cleanUrl.replace(/\.html$/, '');
|
139
|
+
if (cleanUrls && cleanUrl.endsWith('/index')) cleanUrl = cleanUrl.replace(/\/index$/, '/');
|
140
|
+
} else if (!cleanUrl.endsWith('.html')) {
|
137
141
|
if (cleanUrl.endsWith('/')) cleanUrl += 'index.html';
|
138
142
|
else cleanUrl += '.html';
|
139
143
|
}
|
140
|
-
if (cleanUrls && cleanUrl.endsWith('/')) cleanUrl += 'index';
|
141
|
-
if (cleanUrls && cleanUrl.endsWith('.html')) cleanUrl = cleanUrl.replace(/\.html$/, '');
|
142
144
|
return addLeadingSlash(hash ? `${cleanUrl}#${hash}` : cleanUrl);
|
143
145
|
}
|
144
146
|
function withoutLang(path, langs) {
|
package/dist/node-utils.d.ts
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
import {
|
1
|
+
import type { MdxJsxAttribute } from 'mdast-util-mdx-jsx';
|
2
|
+
import type { MdxJsxAttributeValueExpression } from 'mdast-util-mdx-jsx';
|
3
|
+
import type { MdxJsxExpressionAttribute } from 'mdast-util-mdx-jsx';
|
2
4
|
import type { MdxJsxFlowElement } from 'mdast-util-mdx-jsx';
|
3
5
|
import type { MdxJsxTextElement } from 'mdast-util-mdx-jsx';
|
4
6
|
import type { PluggableList } from 'unified';
|
@@ -204,7 +206,9 @@ declare interface FrontMatterMeta {
|
|
204
206
|
[key: string]: unknown;
|
205
207
|
}
|
206
208
|
|
207
|
-
export declare
|
209
|
+
export declare function getNodeAttribute(node: MdxJsxFlowElement | MdxJsxTextElement, attrName: string, attribute?: false): string | MdxJsxAttributeValueExpression | null | undefined;
|
210
|
+
|
211
|
+
export declare function getNodeAttribute(node: MdxJsxFlowElement | MdxJsxTextElement, attrName: string, attribute: true): MdxJsxAttribute | MdxJsxExpressionAttribute | undefined;
|
208
212
|
|
209
213
|
declare interface Header {
|
210
214
|
id: string;
|
package/dist/node-utils.js
CHANGED
@@ -66,7 +66,10 @@ var __webpack_exports__ = {};
|
|
66
66
|
customId
|
67
67
|
];
|
68
68
|
};
|
69
|
-
|
69
|
+
function getNodeAttribute(node, attrName, attribute) {
|
70
|
+
const found = node.attributes.find((attr)=>'name' in attr && attr.name === attrName);
|
71
|
+
return attribute ? found : found?.value;
|
72
|
+
}
|
70
73
|
const external_node_path_namespaceObject = require("node:path");
|
71
74
|
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
72
75
|
const external_gray_matter_namespaceObject = require("gray-matter");
|
package/dist/node-utils.mjs
CHANGED
@@ -14,7 +14,10 @@ const extractTextAndId = (title)=>{
|
|
14
14
|
customId
|
15
15
|
];
|
16
16
|
};
|
17
|
-
|
17
|
+
function getNodeAttribute(node, attrName, attribute) {
|
18
|
+
const found = node.attributes.find((attr)=>'name' in attr && attr.name === attrName);
|
19
|
+
return attribute ? found : found?.value;
|
20
|
+
}
|
18
21
|
function loadFrontMatter(source, filepath, root, outputWarning = false) {
|
19
22
|
try {
|
20
23
|
const { content, data } = (0, __WEBPACK_EXTERNAL_MODULE_gray_matter_90c6cd0b__["default"])(source);
|