From 53e68ba386f4daabd1b6a9e183830132bbf27e99 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Thu, 13 Nov 2025 18:17:48 +0700 Subject: fix sitemap --- src/pages/sitemap/products.xml.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/pages/sitemap/products.xml.js') diff --git a/src/pages/sitemap/products.xml.js b/src/pages/sitemap/products.xml.js index 5ed6b759..b3db3b93 100644 --- a/src/pages/sitemap/products.xml.js +++ b/src/pages/sitemap/products.xml.js @@ -1,12 +1,18 @@ import productSearchApi from '@/lib/product/api/productSearchApi'; import { create } from 'xmlbuilder'; -import _ from 'lodash-contrib'; export async function getServerSideProps({ res }) { const baseUrl = process.env.SELF_HOST + '/sitemap/products'; const limit = 2500; - const query = { limit }; - const products = await productSearchApi({ query: _.toQuery(query) }); + + // ⬇️ Ganti ke URLSearchParams biar key "source" gak hilang + const params = new URLSearchParams({ + limit, + source: 'sitemap', + }).toString(); + + const products = await productSearchApi({ query: params }); + const pageCount = Math.ceil(products.response.numFound / limit); const pages = Array.from({ length: pageCount }, (_, i) => i + 1); const sitemapIndex = create('sitemapindex', { encoding: 'UTF-8' }).att( @@ -15,7 +21,6 @@ export async function getServerSideProps({ res }) { ); const date = new Date(); - // const date = '2025-10-30'; pages.forEach((page) => { const sitemap = sitemapIndex.ele('sitemap'); sitemap.ele('loc', `${baseUrl}/${page}.xml`); -- cgit v1.2.3