mirror of
https://github.com/vercel/commerce.git
synced 2025-05-14 21:47:51 +00:00
HomeProduct: filter collections list to types
This commit is contained in:
parent
cf48cc26cc
commit
5b9af9bcdb
@ -9,8 +9,15 @@ import { PriceRanges } from '/components/price.js';
|
|||||||
import styles from './styles.module.scss';
|
import styles from './styles.module.scss';
|
||||||
|
|
||||||
export async function HomeProduct({ product }) {
|
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 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 (
|
return (
|
||||||
<Link
|
<Link
|
||||||
@ -25,9 +32,7 @@ export async function HomeProduct({ product }) {
|
|||||||
/>
|
/>
|
||||||
<p>{product?.title}</p>
|
<p>{product?.title}</p>
|
||||||
{collections && collections.length > 0 && (
|
{collections && collections.length > 0 && (
|
||||||
<p>{`(${collections
|
<p>{`(${collections.join(', ')})`}</p>
|
||||||
?.map(collection => collection?.title)
|
|
||||||
.join(', ')})`}</p>
|
|
||||||
)}
|
)}
|
||||||
<PriceRanges product={product} />
|
<PriceRanges product={product} />
|
||||||
</Link>
|
</Link>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user