From c317ca6ea7b22062adf0c8897cec63ba1e847b9c Mon Sep 17 00:00:00 2001 From: dadachann <185672915+dadachann@users.noreply.github.com> Date: Fri, 4 Sep 2026 14:36:47 +0000 Subject: [PATCH] fix: render platform logos in navigation --- press.config.tsx | 32 ++++++++++++++++++++++++++- tests/fumapress-static-build.test.mjs | 23 +++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/press.config.tsx b/press.config.tsx index f2811f3f1..7a5d19d0a 100644 --- a/press.config.tsx +++ b/press.config.tsx @@ -22,6 +22,32 @@ function nodeName(node: PageTreeNode) { return typeof node.name === "string" ? node.name : ""; } +function renderNavigationIcon(icon: PageTreeNode["icon"]) { + if (typeof icon !== "string" || !icon.startsWith("/")) return icon; + return ( + + ); +} + +function renderNavigationIcons(node: PageTreeNode): PageTreeNode { + if (node.type === "folder") { + return { + ...node, + icon: renderNavigationIcon(node.icon), + index: node.index + ? { ...node.index, icon: renderNavigationIcon(node.index.icon) } + : undefined, + children: node.children.map(renderNavigationIcons), + }; + } + return { ...node, icon: renderNavigationIcon(node.icon) }; +} + const openApiTagOrder = Object.fromEntries(LOCALES.map((locale) => { const spec = JSON.parse(readFileSync(`openapi/service-api-${locale}.json`, "utf8")); const tags: string[] = []; @@ -329,7 +355,11 @@ export default defineConfig({ sourceTree = (await context.getLoader()).getPageTree(page.locale); sourceTrees.set(locale, sourceTree); } - props.layoutProps.tree = sectionizeMintlifyTree(props.layoutProps.tree, sourceTree, locale); + props.layoutProps.tree = { + ...props.layoutProps.tree, + children: sectionizeMintlifyTree(props.layoutProps.tree, sourceTree, locale) + .children.map(renderNavigationIcons), + }; return props; }); } diff --git a/tests/fumapress-static-build.test.mjs b/tests/fumapress-static-build.test.mjs index e3291f82e..1aa938b84 100644 --- a/tests/fumapress-static-build.test.mjs +++ b/tests/fumapress-static-build.test.mjs @@ -96,6 +96,29 @@ test("representative localized guides and canonical host are emitted", async () assert.doesNotMatch(robots, /https:\/\/docs\.langbot\.app\//); }); +test("platform navigation renders logo assets instead of icon path text", async () => { + for (const locale of ["en", "zh", "ja"]) { + const html = await readFile( + path.join(publicRoot, locale, "usage/platforms/discord/index.html"), + "utf8", + ); + const asideStart = html.indexOf('