From cd86275638f7e9fb8ffc1abb62c2f18f71bf9308 Mon Sep 17 00:00:00 2001 From: urzeye <20869204+urzeye@users.noreply.github.com> Date: Wed, 22 Jul 2026 07:32:05 +0800 Subject: [PATCH] fix(docs): repair broken documentation links (#4330) * fix(docs): repair broken documentation links * revert(docs): restore ACP protocol naming --- frontend/src/app/[lang]/docs/layout.tsx | 18 +--- frontend/src/app/blog/layout.tsx | 2 +- frontend/src/components/docs/docs-page-map.ts | 49 +++++++++ .../src/content/en/harness/lead-agent.mdx | 2 +- frontend/src/content/en/harness/subagents.mdx | 2 +- frontend/src/content/en/index.mdx | 12 +-- .../en/introduction/harness-vs-app.mdx | 4 +- ...ider-safety-termination-in-tool-agents.mdx | 2 +- .../src/content/zh/harness/lead-agent.mdx | 2 +- frontend/src/content/zh/harness/subagents.mdx | 2 +- ...ider-safety-termination-in-tool-agents.mdx | 2 +- .../tests/e2e/docs-localized-links.spec.ts | 29 ++++++ .../components/docs/docs-page-map.test.ts | 99 +++++++++++++++++++ .../tests/unit/content/docs-links.test.ts | 89 +++++++++++++++++ 14 files changed, 284 insertions(+), 30 deletions(-) create mode 100644 frontend/src/components/docs/docs-page-map.ts create mode 100644 frontend/tests/unit/components/docs/docs-page-map.test.ts create mode 100644 frontend/tests/unit/content/docs-links.test.ts diff --git a/frontend/src/app/[lang]/docs/layout.tsx b/frontend/src/app/[lang]/docs/layout.tsx index 895da1da8..12b7d4fbd 100644 --- a/frontend/src/app/[lang]/docs/layout.tsx +++ b/frontend/src/app/[lang]/docs/layout.tsx @@ -1,7 +1,7 @@ -import type { PageMapItem } from "nextra"; import { getPageMap } from "nextra/page-map"; import { Layout } from "nextra-theme-docs"; +import { buildLocalizedDocsPageMap } from "@/components/docs/docs-page-map"; import { Footer } from "@/components/landing/footer"; import { Header } from "@/components/landing/header"; import { getLocaleByLang } from "@/core/i18n/locale"; @@ -12,23 +12,11 @@ const i18n = [ { locale: "zh", name: "中文" }, ]; -function formatPageRoute(base: string, items: PageMapItem[]): PageMapItem[] { - return items.map((item) => { - if ("route" in item && !item.route.startsWith(base)) { - item.route = `${base}${item.route}`; - } - if ("children" in item && item.children) { - item.children = formatPageRoute(base, item.children); - } - return item; - }); -} - export default async function DocLayout({ children, params }) { const { lang } = await params; const locale = getLocaleByLang(lang); const pages = await getPageMap(`/${lang}`); - const pageMap = formatPageRoute(`/${lang}/docs`, pages); + const pageMap = buildLocalizedDocsPageMap(`/${lang}/docs`, pages); return ( } pageMap={pageMap} - docsRepositoryBase="https://github.com/bytedance/deerflow/tree/main/frontend/src/content" + docsRepositoryBase="https://github.com/bytedance/deer-flow/tree/main/frontend" footer={