-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsitemap.js
36 lines (33 loc) · 961 Bytes
/
sitemap.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env node
import * as fs from 'node:fs';
import * as zlib from 'node:zlib';
const urls = [
{
link: "https://mcl.sandro.dev",
since: "2023-09-27",
},
{
link: "https://mcl.sandro.dev/es",
since: "2023-10-01",
},
{
link: "https://mcl.sandro.dev/pt",
since: "2023-09-27",
},
{
link: "https://mcl.sandro.dev/fr",
since: "2023-10-01",
},
]
let sitemap = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">";
for (const url of urls) {
sitemap += `<url><loc>${url.link}</loc><lastmod>${url.since}</lastmod></url>`;
}
sitemap += "</urlset>";
console.log('Generating sitemap.xml...')
fs.writeFileSync('dist/sitemap.xml', sitemap);
console.log('Generating sitemap.xml.gz...')
fs.writeFileSync('dist/sitemap.xml.gz', zlib.gzipSync(sitemap));
console.log('Generating sitemap.xml.br...')
fs.writeFileSync('dist/sitemap.xml.br', zlib.brotliCompressSync(sitemap));
console.log('Done')