首次提交:姜十三论坛
后端 Go+Gin:认证/CSRF/限流、板块、帖子、评论、点赞、通知、用户资料、置顶推荐;前端 Next.js 16:发帖/编辑/删除、搜索、分页、点赞、通知中心、设置;基础设施 docker-compose 与配置模板;添加 .gitignore 与专有许可证(保留所有权利)
This commit is contained in:
35
frontend/app/sitemap.ts
Normal file
35
frontend/app/sitemap.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import type { MetadataRoute } from "next";
|
||||
import { fetchPosts, fetchBoards } 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 { boards } = await fetchBoards();
|
||||
for (const board of boards) {
|
||||
entries.push({
|
||||
url: `${baseUrl}/board/${board.id}`,
|
||||
lastModified: new Date(),
|
||||
changeFrequency: "daily",
|
||||
priority: 0.8,
|
||||
});
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user