Skip to content

Commit 6b73396

Browse files
author
dphuang2
committed
encode uri in sitemap
1 parent 97e14f8 commit 6b73396

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

generator/konfig-next-app/src/pages/sitemap.xml.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@ function generateSitemapXml(host: string, pages: PageData[]): string {
1414
return `<?xml version="1.0" encoding="UTF-8"?>
1515
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
1616
${pages
17-
.map(
18-
(page) => `
17+
.map((page) => {
18+
const url = `https://${host}${page.slug}`
19+
return `
1920
<url>
20-
<loc>${`https://${host}${page.slug}`}</loc>
21+
<loc>${encodeURI(url)}</loc>
2122
<changefreq>daily</changefreq>
2223
<priority>0.7</priority>
2324
</url>
2425
`
25-
)
26+
})
2627
.join('')}
2728
</urlset>`
2829
}

0 commit comments

Comments
 (0)