@rspress/shared 0.0.0-next-20230925114748 → 0.0.0-next-20230926070920
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 +1 -35
- package/dist/index.js +13 -23
- package/dist/index.mjs +13 -22
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
@@ -126,10 +126,6 @@ interface Config$1 {
|
|
126
126
|
* Whether to hide the navbar
|
127
127
|
*/
|
128
128
|
hideNavbar?: boolean;
|
129
|
-
/**
|
130
|
-
* Whether to enable the animation for translation pages
|
131
|
-
*/
|
132
|
-
enableContentAnimation?: boolean;
|
133
129
|
}
|
134
130
|
/**
|
135
131
|
* locale config
|
@@ -343,7 +339,6 @@ interface RouteMeta {
|
|
343
339
|
relativePath: string;
|
344
340
|
pageName: string;
|
345
341
|
lang: string;
|
346
|
-
version: string;
|
347
342
|
}
|
348
343
|
interface ReplaceRule {
|
349
344
|
search: string | RegExp;
|
@@ -460,29 +455,12 @@ interface UserConfig<ThemeConfig = Config$1> {
|
|
460
455
|
* Add some extra builder plugins
|
461
456
|
*/
|
462
457
|
builderPlugins?: BuilderPlugin[];
|
463
|
-
/**
|
464
|
-
* Multi version config
|
465
|
-
*/
|
466
|
-
multiVersion?: {
|
467
|
-
/**
|
468
|
-
* The default version
|
469
|
-
*/
|
470
|
-
default?: string;
|
471
|
-
/**
|
472
|
-
* The version list, such as ['v1', 'v2']
|
473
|
-
*/
|
474
|
-
versions: string[];
|
475
|
-
};
|
476
458
|
}
|
477
459
|
type BaseRuntimePageInfo = Omit<PageIndexInfo, 'id' | 'content' | 'domain'>;
|
478
460
|
interface SiteData<ThemeConfig = NormalizedConfig> {
|
479
461
|
root: string;
|
480
462
|
base: string;
|
481
463
|
lang: string;
|
482
|
-
locales: {
|
483
|
-
lang: string;
|
484
|
-
label: string;
|
485
|
-
}[];
|
486
464
|
title: string;
|
487
465
|
description: string;
|
488
466
|
icon: string;
|
@@ -496,10 +474,6 @@ interface SiteData<ThemeConfig = NormalizedConfig> {
|
|
496
474
|
markdown: {
|
497
475
|
showLineNumbers: boolean;
|
498
476
|
};
|
499
|
-
multiVersion: {
|
500
|
-
default: string;
|
501
|
-
versions: string[];
|
502
|
-
};
|
503
477
|
}
|
504
478
|
type PageIndexInfo = {
|
505
479
|
id: number;
|
@@ -509,7 +483,6 @@ type PageIndexInfo = {
|
|
509
483
|
content: string;
|
510
484
|
frontmatter: Record<string, unknown>;
|
511
485
|
lang: string;
|
512
|
-
version: string;
|
513
486
|
domain: string;
|
514
487
|
_filepath: string;
|
515
488
|
_relativePath: string;
|
@@ -643,14 +616,7 @@ declare function removeLeadingSlash(url: string): string;
|
|
643
616
|
declare function removeTrailingSlash(url: string): string;
|
644
617
|
declare function normalizeSlash(url: string): string;
|
645
618
|
declare function isExternalUrl(url: string): boolean;
|
646
|
-
declare function replaceLang(rawUrl: string,
|
647
|
-
current: string;
|
648
|
-
target: string;
|
649
|
-
default: string;
|
650
|
-
}, version: {
|
651
|
-
current: string;
|
652
|
-
default: string;
|
653
|
-
}, base?: string): string;
|
619
|
+
declare function replaceLang(rawUrl: string, targetLang: string, defaultLang: string, langs: string[], base?: string): string;
|
654
620
|
declare const omit: (obj: Record<string, unknown>, keys: string[]) => {
|
655
621
|
[x: string]: unknown;
|
656
622
|
};
|
package/dist/index.js
CHANGED
@@ -1159,36 +1159,26 @@ function normalizeSlash(url) {
|
|
1159
1159
|
function isExternalUrl(url) {
|
1160
1160
|
return url.startsWith("http://") || url.startsWith("https://") || url.startsWith("mailto:") || url.startsWith("tel:");
|
1161
1161
|
}
|
1162
|
-
function replaceLang(rawUrl,
|
1162
|
+
function replaceLang(rawUrl, targetLang, defaultLang, langs, base = "") {
|
1163
1163
|
let url = removeBase(rawUrl, base);
|
1164
1164
|
if (!url) {
|
1165
1165
|
url = "/index.html";
|
1166
1166
|
}
|
1167
|
-
|
1168
|
-
|
1169
|
-
let
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
1174
|
-
|
1175
|
-
langPart = lang.target;
|
1176
|
-
if (lang.current !== lang.default) {
|
1177
|
-
parts.shift();
|
1167
|
+
const originalLang = url.split("/")[1];
|
1168
|
+
const inDefaultLang = !langs.includes(originalLang);
|
1169
|
+
let result;
|
1170
|
+
if (inDefaultLang) {
|
1171
|
+
if (targetLang === defaultLang) {
|
1172
|
+
result = url;
|
1173
|
+
} else {
|
1174
|
+
result = addLeadingSlash(`${targetLang}${url}`);
|
1178
1175
|
}
|
1176
|
+
} else if (targetLang === defaultLang) {
|
1177
|
+
result = url.replace(`/${originalLang}`, "");
|
1179
1178
|
} else {
|
1180
|
-
|
1181
|
-
}
|
1182
|
-
purePathPart = parts.join("/") || "";
|
1183
|
-
if ((versionPart || langPart) && !purePathPart) {
|
1184
|
-
purePathPart = "index.html";
|
1179
|
+
result = url.replace(originalLang, targetLang);
|
1185
1180
|
}
|
1186
|
-
return withBase(
|
1187
|
-
addLeadingSlash(
|
1188
|
-
[versionPart, langPart, purePathPart].filter(Boolean).join("/")
|
1189
|
-
),
|
1190
|
-
base
|
1191
|
-
);
|
1181
|
+
return withBase(result, base);
|
1192
1182
|
}
|
1193
1183
|
var omit = (obj, keys) => {
|
1194
1184
|
const ret = { ...obj };
|
package/dist/index.mjs
CHANGED
@@ -1113,35 +1113,26 @@ function normalizeSlash(url) {
|
|
1113
1113
|
function isExternalUrl(url) {
|
1114
1114
|
return url.startsWith("http://") || url.startsWith("https://") || url.startsWith("mailto:") || url.startsWith("tel:");
|
1115
1115
|
}
|
1116
|
-
function replaceLang(rawUrl,
|
1116
|
+
function replaceLang(rawUrl, targetLang, defaultLang, langs, base = "") {
|
1117
1117
|
let url = removeBase(rawUrl, base);
|
1118
1118
|
if (!url) {
|
1119
1119
|
url = "/index.html";
|
1120
1120
|
}
|
1121
|
-
|
1122
|
-
|
1123
|
-
let
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
langPart = lang.target;
|
1130
|
-
if (lang.current !== lang.default) {
|
1131
|
-
parts.shift();
|
1121
|
+
const originalLang = url.split("/")[1];
|
1122
|
+
const inDefaultLang = !langs.includes(originalLang);
|
1123
|
+
let result;
|
1124
|
+
if (inDefaultLang) {
|
1125
|
+
if (targetLang === defaultLang) {
|
1126
|
+
result = url;
|
1127
|
+
} else {
|
1128
|
+
result = addLeadingSlash(`${targetLang}${url}`);
|
1132
1129
|
}
|
1130
|
+
} else if (targetLang === defaultLang) {
|
1131
|
+
result = url.replace(`/${originalLang}`, "");
|
1133
1132
|
} else {
|
1134
|
-
|
1135
|
-
}
|
1136
|
-
purePathPart = parts.join("/") || "";
|
1137
|
-
if ((versionPart || langPart) && !purePathPart) {
|
1138
|
-
purePathPart = "index.html";
|
1133
|
+
result = url.replace(originalLang, targetLang);
|
1139
1134
|
}
|
1140
|
-
return withBase(
|
1141
|
-
versionPart,
|
1142
|
-
langPart,
|
1143
|
-
purePathPart
|
1144
|
-
].filter(Boolean).join("/")), base);
|
1135
|
+
return withBase(result, base);
|
1145
1136
|
}
|
1146
1137
|
var omit = (obj, keys) => {
|
1147
1138
|
const ret = {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@rspress/shared",
|
3
|
-
"version": "0.0.0-next-
|
3
|
+
"version": "0.0.0-next-20230926070920",
|
4
4
|
"types": "./dist/index.d.ts",
|
5
5
|
"main": "./dist/index.js",
|
6
6
|
"module": "./dist/index.mjs",
|
@@ -22,8 +22,8 @@
|
|
22
22
|
}
|
23
23
|
},
|
24
24
|
"dependencies": {
|
25
|
-
"@modern-js/builder": "
|
26
|
-
"@modern-js/builder-rspack-provider": "
|
25
|
+
"@modern-js/builder": "0.0.0-next-20230925115155",
|
26
|
+
"@modern-js/builder-rspack-provider": "0.0.0-next-20230925115155",
|
27
27
|
"unified": "10.1.2",
|
28
28
|
"chalk": "4.1.2"
|
29
29
|
},
|