From b956ecf96892a2b7e4f43b89be54888ae87c9017 Mon Sep 17 00:00:00 2001 From: Mqdd Date: Wed, 26 Nov 2025 16:08:30 +0700 Subject: add sitemap --- src/pages/sitemap/sitemap.xml.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/pages/sitemap/sitemap.xml.js 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 = ` + +${links + .map((link) => { + return ` + + ${baseUrl}${link.url} + ${new Date().toISOString()} + ${link.changefreq} + ${link.priority} + `; + }) + .join("")} +`; + + res.setHeader("Content-Type", "text/xml"); + res.write(xml); + res.end(); + + return { + props: {}, + }; +} + +export default function Sitemap() { + return null; +} -- cgit v1.2.3