From 5b9af9bcdb9e0b8067ccb10aa8933f1c0a16e7ab Mon Sep 17 00:00:00 2001 From: andr-ew Date: Fri, 21 Jul 2023 20:34:01 -0500 Subject: [PATCH] HomeProduct: filter collections list to types --- components/home/index.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/components/home/index.js b/components/home/index.js index c32d0fe94..2e4801ba1 100644 --- a/components/home/index.js +++ b/components/home/index.js @@ -9,8 +9,15 @@ import { PriceRanges } from '/components/price.js'; import styles from './styles.module.scss'; export async function HomeProduct({ product }) { + const typesMenu = await getMenu('types-nav'); + + const types = typesMenu?.map(item => /search\/(\w+)/.exec(item?.path)?.[1]); const featuredImage = product?.images?.[0]; - const collections = product?.collections?.nodes; + const collections = product?.collections?.nodes + ?.map(col => col?.title) + ?.filter(col => types?.includes(col?.toLowerCase())); + + console.log({ collections }); return (

{product?.title}

{collections && collections.length > 0 && ( -

{`(${collections - ?.map(collection => collection?.title) - .join(', ')})`}

+

{`(${collections.join(', ')})`}

)}