diff --git a/scripts/docs-site/build.mjs b/scripts/docs-site/build.mjs index 2ff21c4b6..b474317d1 100644 --- a/scripts/docs-site/build.mjs +++ b/scripts/docs-site/build.mjs @@ -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); diff --git a/scripts/docs-site/smoke.mjs b/scripts/docs-site/smoke.mjs index f9745f0e2..9c80a02b6 100644 --- a/scripts/docs-site/smoke.mjs +++ b/scripts/docs-site/smoke.mjs @@ -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 (!/