返回 CodeWhale
sitemap.ts
根目录 / web / app / sitemap.ts
1 import type { MetadataRoute } from "next";
2 import { locales } from "@/lib/i18n/config";
3 import { SITE_URL } from "@/lib/page-meta";
4
5 // Public, indexable routes (locale-prefixed). /admin and /api are
6 // intentionally excluded; see app/robots.ts.
7 const PATHS = ["", "/install", "/constitution", "/models", "/runtime", "/docs", "/docs/configuration", "/docs/constitution", "/docs/fleet", "/docs/guide", "/docs/hooks", "/docs/mcp", "/docs/modes", "/docs/runtime-api", "/docs/sandbox", "/docs/subagents", "/docs/tools", "/docs/troubleshooting", "/docs/vocabulary", "/docs/web", "/docs/work", "/faq", "/roadmap", "/feed", "/digest", "/contribute", "/community"];
8
9 export default function sitemap(): MetadataRoute.Sitemap {
10 const lastModified = new Date();
11 // hreflang alternates derive from the canonical locale registry so new
12 // routed locales propagate without a sitemap edit.
13 return PATHS.flatMap((path) =>
14 locales.map((locale) => ({
15 url: `${SITE_URL}/${locale}${path}`,
16 lastModified,
17 alternates: {
18 languages: Object.fromEntries(
19 locales.map((l) => [l, `${SITE_URL}/${l}${path}`]),
20 ),
21 },
22 })),
23 );
24 }
25
25 lines TYPESCRIPT