Skip to content

Commit 6fab893

Browse files
Merge pull request #31 from LelabsTeam/fix/site-2533
disable indexing for some listing pages with query paramns
2 parents 8968e12 + b6d5af2 commit 6fab893

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

vtex/loaders/intelligentSearch/productListingPage.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,9 @@ const searchArgsOf = (props: Props, url: URL, ctx: AppContext) => {
220220
simulationBehavior,
221221
};
222222
};
223+
224+
const DISABLED_QUERY_PARAMS = ["filter", "sort", "term", "map", "q", "page"];
225+
223226
const PAGE_TYPE_TO_MAP_PARAM = {
224227
Brand: "brand",
225228
Collection: "productClusterIds",
@@ -459,7 +462,6 @@ const loader = async (
459462
const hasNextPage = Boolean(pagination.next.proxyUrl);
460463
const hasPreviousPage = paramnPage > 1;
461464
const currentSearchParams = new URLSearchParams(url.searchParams);
462-
463465
const getPageUrl = (value: number) => {
464466
const pageCurrentExist = url.pathname.match(PAGE_REGEX);
465467
const queryParamns = currentSearchParams.toString()
@@ -472,6 +474,8 @@ const loader = async (
472474
: `${url.pathname}/page${paramnPage + 1}${queryParamns} `;
473475
};
474476

477+
const pageIndex = Array.from(currentSearchParams.keys()).some(key => key.split(".").some(paramn => DISABLED_QUERY_PARAMS.includes(paramn)));
478+
475479
return {
476480
"@type": "ItemList",
477481
breadcrumb: {
@@ -491,11 +495,12 @@ const loader = async (
491495
pageTypes: allPageTypes.map(parsePageType),
492496
},
493497
sortOptions,
494-
seo: safeJsonSerialize(pageTypesToSeo(
498+
seo: {...safeJsonSerialize(pageTypesToSeo(
495499
currentPageTypes,
496500
baseUrl,
497501
hasPreviousPage ? paramnPage : undefined,
498-
)),
502+
)),
503+
noIndexing: pageIndex},
499504
};
500505
};
501506
export const cache = "stale-while-revalidate";

0 commit comments

Comments
 (0)