2023-07-09 15:55:41 +08:00
|
|
|
import { MetadataRoute } from 'next'
|
|
|
|
import { allBlogs } from 'contentlayer/generated'
|
|
|
|
import siteMetadata from '@/data/siteMetadata'
|
|
|
|
|
2024-10-31 22:49:51 +08:00
|
|
|
export const dynamic = 'force-static'
|
|
|
|
|
2023-07-09 15:55:41 +08:00
|
|
|
export default function sitemap(): MetadataRoute.Sitemap {
|
|
|
|
const siteUrl = siteMetadata.siteUrl
|
2023-11-17 18:51:15 +09:00
|
|
|
|
2023-11-20 23:12:38 +08:00
|
|
|
const blogRoutes = allBlogs
|
|
|
|
.filter((post) => !post.draft)
|
2023-11-17 18:51:15 +09:00
|
|
|
.map((post) => ({
|
|
|
|
url: `${siteUrl}/${post.path}`,
|
|
|
|
lastModified: post.lastmod || post.date,
|
|
|
|
}))
|
2023-07-09 15:55:41 +08:00
|
|
|
|
2024-11-15 14:52:06 -06:00
|
|
|
const routes = ['', 'blog','likes', 'projects', 'tags'].map((route) => ({
|
2023-07-09 15:55:41 +08:00
|
|
|
url: `${siteUrl}/${route}`,
|
|
|
|
lastModified: new Date().toISOString().split('T')[0],
|
|
|
|
}))
|
|
|
|
|
|
|
|
return [...routes, ...blogRoutes]
|
|
|
|
}
|