hexo-theme-linen 1.0.38 → 1.0.40
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/package.json
CHANGED
package/scripts/helpers/tools.js
CHANGED
|
@@ -86,13 +86,23 @@ hexo.extend.helper.register("getTranslationPage", function () {
|
|
|
86
86
|
: false;
|
|
87
87
|
let origin =
|
|
88
88
|
config?.theme_config?.siteOriginLocaleMap?.[targetLanguage] || config.url;
|
|
89
|
-
|
|
89
|
+
// `url_for` includes the current site's `root` (for example, the GitHub
|
|
90
|
+
// Pages repository path). The locale origin may already include its own
|
|
91
|
+
// root, so only append the page path portion to avoid duplicating it.
|
|
92
|
+
const rootPath = String(config.root || "/").replace(/^\/+|\/+$/g, "");
|
|
93
|
+
const siteRoot = rootPath ? `/${rootPath}/` : "/";
|
|
94
|
+
let pagePath = this.url_for(page.path);
|
|
95
|
+
if (siteRoot !== "/" && pagePath.startsWith(siteRoot)) {
|
|
96
|
+
pagePath = pagePath.slice(siteRoot.length - 1);
|
|
97
|
+
}
|
|
98
|
+
const originBase = String(origin || "").replace(/\/+$/, "");
|
|
99
|
+
let targetLanguagePath = `${originBase}/${String(pagePath).replace(/^\/+/, "")}`;
|
|
90
100
|
if (page?.seriesInfo?.mappingName) {
|
|
91
|
-
targetLanguagePath = `${
|
|
101
|
+
targetLanguagePath = `${originBase}/series/${page?.seriesInfo?.mappingName}/`;
|
|
92
102
|
}
|
|
93
103
|
if (this.is_category()) {
|
|
94
104
|
if (categoriesInfo?.[page.category]?.mappingName) {
|
|
95
|
-
targetLanguagePath = `${
|
|
105
|
+
targetLanguagePath = `${originBase}/categories/${
|
|
96
106
|
categoriesInfo?.[page.category]?.mappingName
|
|
97
107
|
}/`;
|
|
98
108
|
} else {
|
|
@@ -101,7 +111,7 @@ hexo.extend.helper.register("getTranslationPage", function () {
|
|
|
101
111
|
}
|
|
102
112
|
if (this.is_tag()) {
|
|
103
113
|
if (tagsInfo?.[page.tag]?.mappingName) {
|
|
104
|
-
targetLanguagePath = `${
|
|
114
|
+
targetLanguagePath = `${originBase}/tags/${tagsInfo?.[page.tag]?.mappingName}/`;
|
|
105
115
|
} else {
|
|
106
116
|
hasTranslatation = false;
|
|
107
117
|
}
|