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
|
export async function getServerSideProps({ res }) {
const baseUrl = "http://localhost:2100";
// LIST URL yang mau dimasukin ke sitemap
const links = [
{ url: "/", changefreq: "daily", priority: 1.0 },
{ url: "/shop/brands", changefreq: "weekly", priority: 0.8 },
{ url: "/shop/promo", changefreq: "weekly", priority: 0.8 },
{ url: "/tentang-kami", changefreq: "monthly", priority: 0.5 },
];
// generate XML
const xml = `<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
${links
.map((link) => {
return `
<url>
<loc>${baseUrl}${link.url}</loc>
<lastmod>${new Date().toISOString()}</lastmod>
<changefreq>${link.changefreq}</changefreq>
<priority>${link.priority}</priority>
</url>`;
})
.join("")}
</urlset>`;
res.setHeader("Content-Type", "text/xml");
res.write(xml);
res.end();
return {
props: {},
};
}
export default function Sitemap() {
return null;
}
|