Skip to content

Commit c8930b8

Browse files
0618zhamujun
andauthored
fix(sitemap): dynamically generate urls (#1950)
Co-authored-by: MJ☔ <[email protected]>
1 parent 858681b commit c8930b8

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

docs/scripts/generate-sitemap-robotstxt.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ async function generateSitemap() {
6767
<?xml version="1.0" encoding="UTF-8"?>
6868
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
6969
<url>
70-
<loc>https://ui.docs.amplify.aws</loc>
70+
<loc>${process.env.SITE_URL}</loc>
7171
<changefreq>weekly</changefreq>
7272
<priority>0.5</priority>
7373
<lastmod>2022-05-19T16:24:03.254Z</lastmod>
@@ -95,7 +95,9 @@ async function generateSitemap() {
9595
9696
return `
9797
<url>
98-
<loc>${'https://ui.docs.amplify.aws'}${route}</loc>
98+
<loc>${
99+
process.env.SITE_URL ?? 'https://ui.docs.amplify.aws'
100+
}${route}</loc>
99101
<changefreq>weekly</changefreq>
100102
<priority>${priority}</priority>
101103
<lastmod>${new Date().toISOString()}</lastmod>
@@ -140,7 +142,7 @@ Allow: /
140142
Host: ui.docs.amplify.aws
141143
142144
# Sitemaps
143-
Sitemap: ${'https://ui.docs.amplify.aws'}
145+
Sitemap: ${process.env.SITE_URL ?? 'https://ui.docs.amplify.aws'}/sitemap.xml
144146
`;
145147
writeFileSync(path.resolve(__dirname, '../public/robots.txt'), txt);
146148
console.log('🤖✅ robots.txt generated.');

0 commit comments

Comments
 (0)