Skip to content

Commit

Permalink
feat(site/blog): change sitemap
Browse files Browse the repository at this point in the history
  • Loading branch information
qhanw committed Sep 19, 2023
1 parent 8ca518d commit 9ed35b4
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions site/blog/app/sitemap.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
import { MetadataRoute } from "next";

export default function sitemap(): MetadataRoute.Sitemap {
import { getAllPosts } from "@/lib/posts";

export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
// 远程获取博客列表
const posts = await getAllPosts();

// 转换为博客的 sitemap
const maps: MetadataRoute.Sitemap = posts.map((post) => ({
url: `https://qhan.wang/posts/${post.slug}`,
lastModified: new Date(),
changeFrequency: "weekly",
priority: 0.6,
}));

// // 加入本地的其他路由页面
// const routes = ["", "/about", "/blog"].map((route) => ({
// url: `https://xxx.com${route}`,
// lastModified: new Date().toISOString(),
// }));

return [
{
url: "https://qhan.wang",
Expand All @@ -9,16 +28,17 @@ export default function sitemap(): MetadataRoute.Sitemap {
priority: 1,
},
{
url: "https://qhan.wang/stories",
url: "https://qhan.wang/posts",
lastModified: new Date(),
changeFrequency: "weekly",
priority: 0.8,
},
{
url: "https://qhan.wang.com/blog",
url: "https://qhan.wang.com/projects",
lastModified: new Date(),
changeFrequency: "weekly",
priority: 0.5,
priority: 0.8,
},
...maps,
];
}

1 comment on commit 9ed35b4

@vercel
Copy link

@vercel vercel bot commented on 9ed35b4 Sep 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

qhan – ./

qhan.wang
qhan-git-main-qhanw.vercel.app
qhan-qhanw.vercel.app

Please sign in to comment.