mirror of
https://github.com/r-freeman/portfolio.git
synced 2024-11-11 18:45:41 +00:00
Fix formatiing in generateSitemap
This commit is contained in:
parent
b6f13fd99a
commit
d8157c148b
@ -6,24 +6,24 @@ import {writeFile} from 'fs/promises'
|
||||
const BASE_URL = process.env.NEXT_PUBLIC_SITE_URL
|
||||
|
||||
async function createSitemap(pages) {
|
||||
const sitemap = `<?xml version="1.0" encoding="UTF-8"?>
|
||||
const sitemap =
|
||||
`<?xml version="1.0" encoding="UTF-8"?>
|
||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||
${pages.map((url) => {
|
||||
return `
|
||||
<url>
|
||||
${pages.map((url) =>
|
||||
`<url>
|
||||
<loc>${url}</loc>
|
||||
<lastmod>${new Date().toISOString()}</lastmod>
|
||||
<changefreq>monthly</changefreq>
|
||||
<priority>1.0</priority>
|
||||
</url>`
|
||||
}).join("")}
|
||||
</urlset>`
|
||||
</url>`).join('')}
|
||||
</urlset>`.replace(/(\s\s+|\t)/g, ' ').trim()
|
||||
|
||||
await writeFile('./public/sitemap.xml', sitemap, 'utf8')
|
||||
}
|
||||
|
||||
async function createRobots() {
|
||||
const robots = `# *
|
||||
const robots =
|
||||
`# *
|
||||
User-agent: *
|
||||
Allow: /
|
||||
|
||||
@ -31,7 +31,7 @@ Allow: /
|
||||
Host: ${BASE_URL}
|
||||
|
||||
# Sitemaps
|
||||
Sitemap: ${BASE_URL}/sitemap.xml`
|
||||
Sitemap: ${BASE_URL}/sitemap.xml`.replace(/(\s\s+|\t)/g, ' ').trim()
|
||||
|
||||
await writeFile('./public/robots.txt', robots, 'utf8')
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user