import 'server-only'; import Link from 'next/link'; import Image from 'next/image'; import { getCollectionProducts, getMenu } from 'lib/shopify'; import styles from './styles.module.scss'; import { PriceRanges } from '/components/price'; 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 ?.map(col => col?.title) ?.filter(col => types?.includes(col?.toLowerCase())); return ( {/* TODO: optimize srcset (adjusting based on featured status) */} {featuredImage?.altText}

{product?.title}

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

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

)}
); } const productIsFeatured = product => product?.collections?.nodes ?.map(collection => collection?.handle) .includes('featured'); //TODO: suspense export async function HomeProductsList({ collection }) { const products = await getCollectionProducts({ collection, }); return ( <> {products.length === 0 ? (

{`No products found`}

) : ( )} ); } //TODO: suspense export async function TypesNav() { const typesMenu = await getMenu('types-nav'); return (

Filter: {typesMenu?.map((menuItem, i) => ( {`${menuItem?.title}`} {`${ i == typesMenu.length - 1 ? '.' : ',' } `} ))}

); } export const HomeNav = () => (
Information
);