forked from Tonomy-Foundation/Tonomy-App-Websites
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate-sitemap.js
More file actions
72 lines (62 loc) · 1.21 KB
/
generate-sitemap.js
File metadata and controls
72 lines (62 loc) · 1.21 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import fs from "fs";
console.log("Generating sitemap...");
console.log("Args", process.argv);
const site = process.argv[2];
const demoUrl = "http://host.docker.internal:3001";
const accountUrl = "http://host.docker.internal:3000";
const demoRoutes = [
{
path: "/",
},
{
path: "/home",
},
{
path: "/user-home",
},
{
path: "/blockchain-tx",
},
{
path: "/messages",
},
{
path: "/w3c-vcs",
},
{
path: "/callback",
},
];
const accountsRoutes = [
{
path: "/",
},
{
path: "/download",
},
{
path: "/login",
},
{
path: "/callback",
},
];
if (["demo", "accounts"].indexOf(site) === -1) {
throw new Error("Invalid site name");
}
const urlToUse = site === "demo" ? demoUrl : accountUrl;
const routesToUse = site === "demo" ? demoRoutes : accountsRoutes;
const sitemapXml = `<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
${routesToUse
.map(
(route) => `
<url>
<loc>${urlToUse}${route.path}</loc>
</url>`
)
.join("\n")}
</urlset>
`;
fs.writeFileSync("dist/sitemap.xml", sitemapXml);
console.log("Sitemap generated successfully.");