diff options
| author | Miqdad <ahmadmiqdad27@gmail.com> | 2025-11-13 18:17:48 +0700 |
|---|---|---|
| committer | Miqdad <ahmadmiqdad27@gmail.com> | 2025-11-13 18:17:48 +0700 |
| commit | 53e68ba386f4daabd1b6a9e183830132bbf27e99 (patch) | |
| tree | 09636bc9399d6ba837893314e778a404bae1b3a4 /src/pages/sitemap/products.xml.js | |
| parent | 48c1110541a30bb33726a6f46737615b98f1d9c5 (diff) | |
<MIqdad> fix sitemapfix_indexing_google
Diffstat (limited to 'src/pages/sitemap/products.xml.js')
| -rw-r--r-- | src/pages/sitemap/products.xml.js | 13 |
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`); |
