summaryrefslogtreecommitdiff
path: root/src/pages/sitemap/products.xml.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/pages/sitemap/products.xml.js')
-rw-r--r--src/pages/sitemap/products.xml.js13
1 files changed, 9 insertions, 4 deletions
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`);