@rspress-theme-anatole/theme-default 0.6.7 → 0.6.9
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/bundle.js +38 -13
- package/package.json +3 -3
package/dist/bundle.js
CHANGED
|
@@ -757,6 +757,9 @@ function Sidebar(props) {
|
|
|
757
757
|
const rawSidebarData = useSidebarData();
|
|
758
758
|
const [sidebarData, setSidebarData] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(() => rawSidebarData.filter(Boolean).flat());
|
|
759
759
|
const pathname = decodeURIComponent(rawPathname);
|
|
760
|
+
const { siteData } = (0, __WEBPACK_EXTERNAL_MODULE__rspress_runtime_0abd3046__.usePageData)();
|
|
761
|
+
const { base } = siteData;
|
|
762
|
+
|
|
760
763
|
const activeMatcher = useActiveMatcher();
|
|
761
764
|
(0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(() => {
|
|
762
765
|
if ((0, __WEBPACK_EXTERNAL_MODULE__rspress_shared_baa012d0__.inBrowser)()) {
|
|
@@ -843,23 +846,34 @@ function Sidebar(props) {
|
|
|
843
846
|
if (parts.length && parts[parts.length - 1].includes('.')) {
|
|
844
847
|
parts.pop();
|
|
845
848
|
}
|
|
846
|
-
|
|
847
|
-
//
|
|
848
|
-
const first = parts[0] || '
|
|
849
|
+
|
|
850
|
+
// 取前三级
|
|
851
|
+
const first = parts[0] || '';
|
|
849
852
|
const second = parts[1] || '';
|
|
850
|
-
|
|
851
|
-
const
|
|
853
|
+
const third = parts[2] || '';
|
|
854
|
+
const base_trimmed = base.replace(/^\/|\/$/g, '');;
|
|
852
855
|
|
|
856
|
+
const langArr = ['en', 'vn', 'zh'];
|
|
853
857
|
let fileName = '';
|
|
854
|
-
if (
|
|
855
|
-
fileName
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
858
|
+
if (first === base_trimmed) {
|
|
859
|
+
fileName += `/${base_trimmed}`;
|
|
860
|
+
|
|
861
|
+
if (!langArr.includes(second)) {
|
|
862
|
+
fileName += `/${second}.pdf`;
|
|
863
|
+
}
|
|
864
|
+
else if (third) {
|
|
865
|
+
fileName = `/${second}_${third}.pdf`;
|
|
866
|
+
}
|
|
859
867
|
}
|
|
860
868
|
else {
|
|
861
|
-
|
|
869
|
+
if (!langArr.includes(first)) {
|
|
870
|
+
fileName = `/${first}.pdf`;
|
|
871
|
+
}
|
|
872
|
+
else if (second) {
|
|
873
|
+
fileName = `/${first}_${second}.pdf`;
|
|
874
|
+
}
|
|
862
875
|
}
|
|
876
|
+
|
|
863
877
|
return fileName;
|
|
864
878
|
})(),
|
|
865
879
|
target: "_blank", // 新开标签页
|
|
@@ -1133,7 +1147,7 @@ function DocLayout(props) {
|
|
|
1133
1147
|
const { headingTitle, title, toc = [], frontmatter, routePath } = page;
|
|
1134
1148
|
const [tabData, setTabData] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)({});
|
|
1135
1149
|
const headers = toc;
|
|
1136
|
-
const { themeConfig, base } = siteData;
|
|
1150
|
+
const { themeConfig, base, lang } = siteData;
|
|
1137
1151
|
const enableScrollToTop = themeConfig.enableScrollToTop ?? false;
|
|
1138
1152
|
const localesData = useLocaleSiteData();
|
|
1139
1153
|
const outlineTitle = localesData?.outlineTitle || themeConfig?.outlineTitle || 'ON THIS PAGE';
|
|
@@ -1190,6 +1204,14 @@ function DocLayout(props) {
|
|
|
1190
1204
|
|
|
1191
1205
|
const breadcrumb = findActiveBreadcrumb(sidebarData, activeMatcher) || [];
|
|
1192
1206
|
|
|
1207
|
+
// 判断 str 是否以 prefix 开头,如果是则移除 prefix
|
|
1208
|
+
function removePrefix(str, prefix) {
|
|
1209
|
+
if (str.startsWith(prefix)) {
|
|
1210
|
+
return str.slice(prefix.length);
|
|
1211
|
+
}
|
|
1212
|
+
return str;
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1193
1215
|
const breadcrumbNav = breadcrumb.map((item, idx) => {
|
|
1194
1216
|
const normalizedBase = base.endsWith('/') ? base.slice(0, -1) : base;
|
|
1195
1217
|
|
|
@@ -1223,6 +1245,10 @@ function DocLayout(props) {
|
|
|
1223
1245
|
window.location.href = normalizedBase + item.link + '.html';
|
|
1224
1246
|
return;
|
|
1225
1247
|
} else {
|
|
1248
|
+
if (lang && item.key.startsWith(`${lang}/`)) {
|
|
1249
|
+
//只移除最开头的lang
|
|
1250
|
+
item.key = removePrefix(item.key, `${lang}`);
|
|
1251
|
+
}
|
|
1226
1252
|
// 父级不可点击,跳转到当前级别下的第一个子节点页面
|
|
1227
1253
|
window.location.href = normalizedBase + (item.key.startsWith('/') ? item.key : `/${item.key}`) + '.html';
|
|
1228
1254
|
return;
|
|
@@ -3000,7 +3026,6 @@ function HomeFooter() {
|
|
|
3000
3026
|
style: {
|
|
3001
3027
|
display: "flex",
|
|
3002
3028
|
fontWeight: "400",
|
|
3003
|
-
|
|
3004
3029
|
}
|
|
3005
3030
|
}),
|
|
3006
3031
|
(0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("p", {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rspress-theme-anatole/theme-default",
|
|
3
3
|
"author": "Anatole Tong",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.9",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"sideEffects": [
|
|
7
7
|
"*.css",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"types": "./dist/bundle.d.ts",
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@mdx-js/react": "2.3.0",
|
|
24
|
-
"@rspress-theme-anatole/rspress-plugin-mermaid": "0.6.
|
|
25
|
-
"@rspress-theme-anatole/shared": "0.6.
|
|
24
|
+
"@rspress-theme-anatole/rspress-plugin-mermaid": "0.6.9",
|
|
25
|
+
"@rspress-theme-anatole/shared": "0.6.9",
|
|
26
26
|
"@rspress/runtime": "1.43.8",
|
|
27
27
|
"body-scroll-lock": "4.0.0-beta.0",
|
|
28
28
|
"copy-to-clipboard": "^3.3.3",
|