diff --git a/src/lib/generateSitemap.js b/src/lib/generateSitemap.js index 02b6d3e..23f6444 100644 --- a/src/lib/generateSitemap.js +++ b/src/lib/generateSitemap.js @@ -6,32 +6,32 @@ import {writeFile} from 'fs/promises' const BASE_URL = process.env.NEXT_PUBLIC_SITE_URL async function createSitemap(pages) { - const sitemap = ` - - ${pages.map((url) => { - return ` - - ${url} - ${new Date().toISOString()} - monthly - 1.0 -` - }).join("")} -` + const sitemap = + ` + + ${pages.map((url) => + ` + ${url} + ${new Date().toISOString()} + monthly + 1.0 + `).join('')} + `.replace(/(\s\s+|\t)/g, ' ').trim() await writeFile('./public/sitemap.xml', sitemap, 'utf8') } async function createRobots() { - const robots = `# * -User-agent: * -Allow: / - -# Host -Host: ${BASE_URL} - -# Sitemaps -Sitemap: ${BASE_URL}/sitemap.xml` + const robots = + `# * + User-agent: * + Allow: / + + # Host + Host: ${BASE_URL} + + # Sitemaps + Sitemap: ${BASE_URL}/sitemap.xml`.replace(/(\s\s+|\t)/g, ' ').trim() await writeFile('./public/robots.txt', robots, 'utf8') }