fix: restore localized docs navigation

This commit is contained in:
Peter Steinberger 2026-05-06 00:55:31 +01:00
parent 82b5dc961c
commit e000cb93b8
No known key found for this signature in database
2 changed files with 14 additions and 1 deletions

View File

@ -98,7 +98,7 @@ function flattenPages(locale, entries) {
const output = [];
for (const entry of entries) {
if (typeof entry === "string") {
const page = pageByKey.get(pageKey(locale, normalizeSlug(entry)));
const page = pageByKey.get(pageKey(locale, navEntrySlug(locale, entry)));
if (page) output.push(page);
} else if (entry?.pages) {
const nested = flattenPages(locale, entry.pages);
@ -108,6 +108,11 @@ function flattenPages(locale, entries) {
return output;
}
function navEntrySlug(locale, entry) {
const slug = normalizeSlug(entry);
return slug.startsWith(`${locale}/`) ? normalizeSlug(slug.slice(locale.length + 1)) : slug;
}
function writePage(page) {
const nav = navByLocale.get(page.locale) ?? [];
const flat = flattenNav(nav);

View File

@ -7,6 +7,7 @@ const site = path.join(root, "dist", "docs-site");
const required = [
"index.html",
"tools/reactions/index.html",
"it/channels/index.html",
"zh-CN/tools/reactions/index.html",
"de/tools/reactions/index.html",
"de/gateway/heartbeat/index.html",
@ -41,6 +42,13 @@ if (!/data-url="(?:\/docs)?\/zh-CN\/tools\/reactions\/"/.test(zhReactions)) {
if (!/href="(?:\/docs)?\/zh-CN\/tools\/agent-send/.test(zhReactions)) {
throw new Error("zh-CN reactions: article links do not stay in locale");
}
const itChannels = fs.readFileSync(path.join(site, "it/channels/index.html"), "utf8");
if (!/class="tab-link active" href="(?:\/docs)?\/it\/channels\/"/.test(itChannels)) {
throw new Error("it channels: localized tabs are missing active Channels tab");
}
if (!/<section class="nav-section"><h2>Overview<\/h2>/.test(itChannels)) {
throw new Error("it channels: localized sidebar is missing");
}
const index = fs.readFileSync(path.join(site, "index.html"), "utf8");
if (/src="\/assets\//.test(index) || /href="\/assets\//.test(index)) {
throw new Error("index: absolute asset paths were not base-path rewritten");