feat: improve documentation sidebar quick links (#119)

* feat: improve documentation sidebar quick links

* test: update sidebar navigation expectations

---------

Co-authored-by: dadachann <[email protected]>
This commit is contained in:
Hyu
2026-09-05 12:21:22 +08:00
committed by GitHub
co-authored by dadachann
parent 2c5035c5c7
commit a7bca0cdba
4 changed files with 138 additions and 54 deletions
+10 -4
View File
@@ -241,18 +241,24 @@ function extractHeadLinks(html, rel) {
test("rendered navbar and documentation tree use each locale's docs.json labels", async () => {
const expected = {
en: ["Home", "https://langbot.app/en", "Roadmap", "https://langbot.app/en/roadmap", "Guides", "Quick Start", "Installation", "Developers", "Articles", "API Reference"],
zh: ["首页", "https://langbot.app/zh", "路线图", "https://langbot.app/zh/roadmap", "指南", "快速开始", "安装部署", "开发者", "文章", "API 参考"],
ja: ["ホーム", "https://langbot.app/ja", "ロードマップ", "https://langbot.app/ja/roadmap", "ガイド", "クイックスタート", "インストール", "開発者", "記事", "API リファレンス"],
en: ["Roadmap", "https://langbot.app/en/roadmap", "Guides", "Quick Start", "Installation", "Developers", "Articles", "API Reference"],
zh: ["路线图", "https://langbot.app/zh/roadmap", "指南", "快速开始", "安装部署", "开发者", "文章", "API 参考"],
ja: ["ロードマップ", "https://langbot.app/ja/roadmap", "ガイド", "クイックスタート", "インストール", "開発者", "記事", "API リファレンス"],
};
const removedHomeLinks = {
en: "https://langbot.app/en",
zh: "https://langbot.app/zh",
ja: "https://langbot.app/ja",
};
for (const locale of locales) {
const html = await readFile(path.join(publicRoot, locale, "insight/guide/index.html"), "utf8");
for (const value of expected[locale]) assert.ok(html.includes(value), `${locale} navbar missing ${value}`);
assert.ok(!html.includes(`href="${removedHomeLinks[locale]}"`), `${locale} navbar still includes Home`);
for (const languageName of ["English", "简体中文", "日本語"]) {
assert.ok(html.includes(languageName), `${locale} language selector missing ${languageName}`);
}
for (const other of locales.filter((item) => item !== locale)) {
assert.ok(!html.includes(expected[other][1]), `${locale} navbar includes ${other} home link`);
assert.ok(!html.includes(expected[other][1]), `${locale} navbar includes ${other} roadmap link`);
}
}
});
+18 -3
View File
@@ -39,15 +39,15 @@ test("navbar is localized and links to locale-aware product pages", async () =>
);
const expected = {
en: {
labels: ["Home", "Cloud", "Extensions", "Blog", "Roadmap"],
labels: ["Cloud", "Extensions", "Blog", "Roadmap"],
roadmap: "https://langbot.app/en/roadmap",
},
cn: {
labels: ["首页", "云服务", "扩展", "博客", "路线图"],
labels: ["云服务", "扩展", "博客", "路线图"],
roadmap: "https://langbot.app/zh/roadmap",
},
jp: {
labels: ["ホーム", "クラウド", "拡張機能", "ブログ", "ロードマップ"],
labels: ["クラウド", "拡張機能", "ブログ", "ロードマップ"],
roadmap: "https://langbot.app/ja/roadmap",
},
};
@@ -58,14 +58,29 @@ test("navbar is localized and links to locale-aware product pages", async () =>
navbar.links.map((link) => link.label),
expected[language].labels,
);
assert.deepEqual(
navbar.links.map((link) => link.icon),
["cloud", "blocks", "newspaper", "map"],
);
assert.equal(navbar.links.at(-1).href, expected[language].roadmap);
assert.equal(navbar.primary.type, "button");
assert.equal(navbar.primary.label, "GitHub");
assert.equal(navbar.primary.icon, "github");
assert.equal(
navbar.primary.href,
"https://github.com/langbot-app/LangBot",
);
}
assert.deepEqual(
docs.navbar.links.map((link) => link.label),
expected.en.labels,
);
assert.deepEqual(
docs.navbar.links.map((link) => link.icon),
["cloud", "blocks", "newspaper", "map"],
);
assert.equal(docs.navbar.primary.icon, "github");
});
test("custom robots policy is served from the Mintlify project root", async () => {