mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-11-03 22:32:27 +08:00
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:
@@ -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
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user