鉴权只认 cookie、SEO 只走 Next、sort 与推荐对齐;删除 Bearer、Go sitemap、post_type 回填等冗余路径。 Co-authored-by: Cursor <cursoragent@cursor.com>
26 lines
683 B
TypeScript
26 lines
683 B
TypeScript
import type { MetadataRoute } from "next";
|
|
import { fetchPosts } from "@/lib/api";
|
|
|
|
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
|
const baseUrl = "http://localhost:3000";
|
|
const entries: MetadataRoute.Sitemap = [
|
|
{ url: `${baseUrl}/`, lastModified: new Date(), changeFrequency: "daily", priority: 1 },
|
|
];
|
|
|
|
try {
|
|
const { posts } = await fetchPosts(1, 100);
|
|
for (const post of posts) {
|
|
entries.push({
|
|
url: `${baseUrl}/post/${post.id}`,
|
|
lastModified: new Date(post.created_at),
|
|
changeFrequency: "weekly",
|
|
priority: 0.6,
|
|
});
|
|
}
|
|
} catch {
|
|
/* 忽略 API 错误 */
|
|
}
|
|
|
|
return entries;
|
|
}
|