VitePress: 修复翻译页缺失功能无效问题

This commit is contained in:
Meow
2026-01-19 19:41:01 +08:00
parent 39d0d66938
commit 531a851a26
2 changed files with 20 additions and 2 deletions
+9
View File
@@ -38,6 +38,14 @@ function toRouteFromDocsRel(relToDocs) {
return route;
}
function ensureEmptyPlaceholder(locale, relNoLocale) {
const tAbs = path.join(DOCS_DIR, locale, relNoLocale); // docs/en/xxx.md
if (fs.existsSync(tAbs)) return;
fs.mkdirSync(path.dirname(tAbs), { recursive: true });
fs.writeFileSync(tAbs, "", "utf8");
}
const zhFiles = walk(DOCS_DIR).filter((p) => {
const rel = path.relative(DOCS_DIR, p).replaceAll("\\", "/");
return !LOCALES.some((l) => rel.startsWith(l + "/"));
@@ -96,6 +104,7 @@ for (const [zhRel, zhAbs] of zhByRel.entries()) {
tLastUpdated: null,
zhLastUpdated: zhISO,
};
ensureEmptyPlaceholder(locale, zhRel);
}
}
}