diff options
| author | Mqdd <ahmadmiqdad27@gmail.com> | 2025-11-26 16:08:30 +0700 |
|---|---|---|
| committer | Mqdd <ahmadmiqdad27@gmail.com> | 2025-11-26 16:08:30 +0700 |
| commit | b956ecf96892a2b7e4f43b89be54888ae87c9017 (patch) | |
| tree | 9b25ebe25a8c01a18ccf18f722ee4e0b52462ef7 | |
| parent | adc316e70faf20ea375b3e590998a36997b6b6e2 (diff) | |
<Miqdad> add sitemapcr_renca_ssr
| -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; +} |
