diff options
Diffstat (limited to 'src/pages/sitemap/sitemap.xml.js')
| -rw-r--r-- | src/pages/sitemap/sitemap.xml.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/pages/sitemap/sitemap.xml.js b/src/pages/sitemap/sitemap.xml.js new file mode 100644 index 00000000..2ab81788 --- /dev/null +++ b/src/pages/sitemap/sitemap.xml.js @@ -0,0 +1,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; +} |
