Skip to content

Commit f6762c3

Browse files
committed
[dev/sitemap-draft-not-include] draft posts are not included in the sitemap
1 parent a17e244 commit f6762c3

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

app/sitemap.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import siteMetadata from '@/data/siteMetadata'
44

55
export default function sitemap(): MetadataRoute.Sitemap {
66
const siteUrl = siteMetadata.siteUrl
7-
const blogRoutes = allBlogs.map((post) => ({
8-
url: `${siteUrl}/${post.path}`,
9-
lastModified: post.lastmod || post.date,
10-
}))
7+
8+
const blogRoutes = allBlogs.filter((post) => !post.draft)
9+
.map((post) => ({
10+
url: `${siteUrl}/${post.path}`,
11+
lastModified: post.lastmod || post.date,
12+
}))
1113

1214
const routes = ['', 'blog', 'projects', 'tags'].map((route) => ({
1315
url: `${siteUrl}/${route}`,

0 commit comments

Comments
 (0)