Open utterances-bot opened 3 years ago
Sweet post, Pedro! Thanks :)
Thanks a lot for this post, was a great starting point! I just added the last published date to the sitemap
const generateSitemap = (posts, url) => {
return `<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
${posts
.map(
({ slug, published_at }) => `
<url>
<loc>https://${url}/${slug}</loc>
<lastmod>${published_at}</lastmod>
</url>`,
)
.join("")}
</urlset>`;
};
... and used the same technique for robots.txt in order to avoid the hardcoded URL.
Generate Dynamic Sitemap with Storyblok and Next.js | Pedro Sousa
Programming, Tech and other random blurbs
https://blog.psousa.dev/posts/generate-dynamic-sitemap-with-storyblok-and-next-js