Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions web/src/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ export const en = {
docs: {
/* 文档区字标:Charter——理想之城的立城宪章,与主字标同字体同字号 */
brand: "Utopia Charter",
ingestTopic: "Ingest interfaces",
mcpTopic: "Agents over MCP",
backTitle: "Back to Utopia",
searchPlaceholder: "Search the docs…",
noResults: "No matches.",
Expand Down
2 changes: 2 additions & 0 deletions web/src/i18n/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ export const zh: Strings = {
},
docs: {
brand: "Utopia Charter",
ingestTopic: "摄入接口",
mcpTopic: "通过 MCP 使用智能体",
backTitle: "返回 Utopia",
searchPlaceholder: "搜索文档…",
noResults: "没有匹配。",
Expand Down
35 changes: 35 additions & 0 deletions web/src/pages/Docs.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { createElement, type ReactNode } from "react";
import { renderToStaticMarkup } from "react-dom/server";
import { afterEach, expect, it, vi } from "vitest";

const usePageTitle = vi.hoisted(() => vi.fn());

vi.mock("@tanstack/react-router", () => ({
Link: ({ children }: { children: ReactNode }) => children,
useNavigate: () => () => {},
useParams: () => ({ slug: "ingest" }),
}));
vi.mock("./HeaderActions", () => ({ HeaderActions: () => null }));
vi.mock("../useTitle", () => ({ usePageTitle }));

afterEach(() => {
vi.unstubAllGlobals();
vi.resetModules();
});

it("uses the selected locale for documentation navigation and the page title", async () => {
vi.stubGlobal("localStorage", {
getItem: (key: string) => key === "utopia.lang" ? "zh" : null,
});
vi.stubGlobal("navigator", { platform: "MacIntel" });
const { DocsPage } = await import("./Docs");
const client = new QueryClient();
const markup = renderToStaticMarkup(
createElement(QueryClientProvider, { client, children: createElement(DocsPage) }),
);

expect(markup).toContain("摄入接口");
expect(markup).toContain("通过 MCP 使用智能体");
expect(usePageTitle).toHaveBeenCalledWith("Utopia", "摄入接口");
});
4 changes: 2 additions & 2 deletions web/src/pages/Docs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import { fetchMe } from "../authSession";

/** 文档清单:slug → 标题 + 内容(构建期打进 bundle) */
const DOCS: { slug: string; title: string; body: string }[] = [
{ slug: "ingest", title: "Ingest interfaces", body: ingestMd },
{ slug: "mcp", title: "Agents over MCP", body: mcpMd },
{ slug: "ingest", title: S.docs.ingestTopic, body: ingestMd },
{ slug: "mcp", title: S.docs.mcpTopic, body: mcpMd },
];

/** 全文检索(客户端,文档已在 bundle 里):命中行 → 文档 + 以命中词为中心的摘录 */
Expand Down
Loading