DEV Community

Discussion on: Auto-Generate sitemap.xml in Next.js

Collapse
 
helloguille profile image
Guillermo Gonzalez • Edited

Thanks! I think there's a bug in the code:

${Object.keys(pathsObj).map(
path => <url>
<loc>https://embiem.me${path}</loc>
<lastmod>${
formatDate(new Date(pathsObj[path].lastModified))
}</lastmod>
</url>

)}

Should be:

${Object.keys(pathsObj).map(
path => <url>
<loc>https://embiem.me${path}</loc>
<lastmod>${
formatDate(new Date(pathsObj[path].lastModified))
}</lastmod>
</url>

).join("")}

The original version is outputting commas between each XML element.