28 lines
651 B
JavaScript
28 lines
651 B
JavaScript
import { fetchBlogPosts } from '../lib/contentful/blogPosts';
|
|
|
|
export default async function sitemap() {
|
|
const paths = [
|
|
{
|
|
url: process.env.NEXT_PUBLIC_HOST,
|
|
lastModified: new Date(),
|
|
changeFrequency: "monthly",
|
|
priority: 1
|
|
}
|
|
]
|
|
|
|
|
|
const blogPosts = await fetchBlogPosts({ preview: false })
|
|
|
|
blogPosts.data.forEach((item) => {
|
|
|
|
paths.push({
|
|
url: `${process.env.NEXT_PUBLIC_HOST}${item.slug}`,
|
|
lastModified: item.createdAt.split('T')[0],
|
|
changeFrequency: 'daily',
|
|
priority: '1.0'
|
|
})
|
|
})
|
|
|
|
return paths
|
|
}
|