@rspress/shared 2.0.0-beta.29 → 2.0.0-beta.30
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 +0 -2
- package/dist/index.js +15 -6
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -423,8 +423,6 @@ export declare function normalizeHref(url?: string, cleanUrls?: boolean, assetEx
|
|
|
423
423
|
|
|
424
424
|
export declare function normalizePosixPath(id: string): string;
|
|
425
425
|
|
|
426
|
-
export declare function normalizeSlash(url: string): string;
|
|
427
|
-
|
|
428
426
|
export declare interface PageData {
|
|
429
427
|
pages: BaseRuntimePageInfo[];
|
|
430
428
|
}
|
package/dist/index.js
CHANGED
|
@@ -64,9 +64,6 @@ function addTrailingSlash(url) {
|
|
|
64
64
|
function removeTrailingSlash(url) {
|
|
65
65
|
return '/' === url.charAt(url.length - 1) ? url.slice(0, -1) : url;
|
|
66
66
|
}
|
|
67
|
-
function normalizeSlash(url) {
|
|
68
|
-
return removeTrailingSlash(addLeadingSlash(normalizePosixPath(url)));
|
|
69
|
-
}
|
|
70
67
|
function isExternalUrl(url = '') {
|
|
71
68
|
return url.startsWith('http://') || url.startsWith('https://') || url.startsWith('mailto:') || url.startsWith('tel:');
|
|
72
69
|
}
|
|
@@ -137,12 +134,24 @@ function withoutLang(path, langs) {
|
|
|
137
134
|
const langRegexp = new RegExp(`^\\/(${langs.join('|')})`);
|
|
138
135
|
return addLeadingSlash(path.replace(langRegexp, ''));
|
|
139
136
|
}
|
|
137
|
+
function normalizeSlash(url) {
|
|
138
|
+
return removeTrailingSlash(addLeadingSlash(normalizePosixPath(url)));
|
|
139
|
+
}
|
|
140
140
|
function withBase(url, base) {
|
|
141
141
|
const normalizedUrl = addLeadingSlash(url);
|
|
142
142
|
const normalizedBase = normalizeSlash(base);
|
|
143
|
-
|
|
143
|
+
const hasBase = normalizedUrl.startsWith(normalizedBase);
|
|
144
|
+
if (hasBase) {
|
|
145
|
+
if (normalizedUrl + '/' === base) return base;
|
|
146
|
+
return normalizedUrl;
|
|
147
|
+
}
|
|
148
|
+
return `${normalizedBase}${normalizedUrl}`;
|
|
144
149
|
}
|
|
145
150
|
function removeBase(url, base) {
|
|
146
|
-
|
|
151
|
+
const normalizedUrl = addLeadingSlash(url);
|
|
152
|
+
const normalizedBase = normalizeSlash(base);
|
|
153
|
+
const removedBaseUrl = normalizedUrl.replace(new RegExp(`^${normalizedBase}`), '');
|
|
154
|
+
if ('' === removedBaseUrl) return '/';
|
|
155
|
+
return removedBaseUrl;
|
|
147
156
|
}
|
|
148
|
-
export { APPEARANCE_KEY, HASH_REGEXP, MDX_OR_MD_REGEXP, QUERY_REGEXP, RSPRESS_TEMP_DIR, SEARCH_INDEX_NAME, addLeadingSlash, addTrailingSlash, utils_cleanUrl as cleanUrl, getSidebarDataGroup, inBrowser, isDataUrl, isDebugMode, isDevDebugMode, isExternalUrl, isProduction, matchNavbar, matchSidebar, normalizeHref, normalizePosixPath,
|
|
157
|
+
export { APPEARANCE_KEY, HASH_REGEXP, MDX_OR_MD_REGEXP, QUERY_REGEXP, RSPRESS_TEMP_DIR, SEARCH_INDEX_NAME, addLeadingSlash, addTrailingSlash, utils_cleanUrl as cleanUrl, getSidebarDataGroup, inBrowser, isDataUrl, isDebugMode, isDevDebugMode, isExternalUrl, isProduction, matchNavbar, matchSidebar, normalizeHref, normalizePosixPath, parseUrl, removeBase, removeHash, removeLeadingSlash, removeTrailingSlash, replaceLang, replaceVersion, slash, withBase, withoutLang };
|
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.30",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/web-infra-dev/rspress.git",
|
|
@@ -32,18 +32,18 @@
|
|
|
32
32
|
"dist"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@rsbuild/core": "~1.
|
|
36
|
-
"@shikijs/rehype": "^3.
|
|
35
|
+
"@rsbuild/core": "~1.5.3",
|
|
36
|
+
"@shikijs/rehype": "^3.12.0",
|
|
37
37
|
"gray-matter": "4.0.3",
|
|
38
38
|
"lodash-es": "^4.17.21",
|
|
39
39
|
"unified": "^11.0.5"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@rslib/core": "0.12.
|
|
42
|
+
"@rslib/core": "0.12.4",
|
|
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.12",
|
|
47
47
|
"mdast-util-mdx-jsx": "^3.2.0",
|
|
48
48
|
"medium-zoom": "1.1.0",
|
|
49
49
|
"rimraf": "^6.0.1",
|