Merge pull request #778 from zziri/dev/sitemap-draft-not-include

draft posts should not be included in the sitemap
This commit is contained in:
Timothy 2023-11-21 00:08:01 +08:00 committed by GitHub
commit e4b6438dca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,10 +4,13 @@ import siteMetadata from '@/data/siteMetadata'
export default function sitemap(): MetadataRoute.Sitemap {
const siteUrl = siteMetadata.siteUrl
const blogRoutes = allBlogs.map((post) => ({
url: `${siteUrl}/${post.path}`,
lastModified: post.lastmod || post.date,
}))
const blogRoutes = allBlogs
.filter((post) => !post.draft)
.map((post) => ({
url: `${siteUrl}/${post.path}`,
lastModified: post.lastmod || post.date,
}))
const routes = ['', 'blog', 'projects', 'tags'].map((route) => ({
url: `${siteUrl}/${route}`,