diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2025-11-13 11:18:34 +0000 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2025-11-13 11:18:34 +0000 |
| commit | 74a38d9794e0c4ec937981a45782ab9c80ebf9ef (patch) | |
| tree | 09636bc9399d6ba837893314e778a404bae1b3a4 /src/pages/sitemap/products.xml.js | |
| parent | 4e24ad6def0e8df890b72f2f7f877424d8ed84cc (diff) | |
| parent | 53e68ba386f4daabd1b6a9e183830132bbf27e99 (diff) | |
Merged in fix_indexing_google (pull request #471)
<MIqdad> fix sitemap
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`); |
