import type { StorefrontApi } from "@shopify/hydrogen"; import Link from "next/link"; import type { COLLECTION_CARD_QUERY } from "@/lib/fragments"; import { shopifyImageUrl, srcSetFor } from "@/lib/image"; /** The typed collection card node. */ export type CollectionCardData = NonNullable< StorefrontApi.ResultOf["collection"] >; type CollectionCardProps = { collection: CollectionCardData; loading?: "eager" | "lazy"; fetchPriority?: "high" | "low" | "auto"; }; /** * Shared `CollectionCard` — an overlay tile (square image, `overlay-dark` * gradient, title-only, stretched link). Reused by the collections index and * the home "shop by category" grid (engineering.md F13). Title-only — no * product count (F5: the Storefront API has no cheap collection count). * * The `.card-link` is a direct child of the relative `.card` `
` so its * `::after` stretched hit area covers the whole card, not just the caption. * The caption is `pointer-events-none` so clicks over the title route to the * card link. Server-rendered. */ export function CollectionCard({ collection, loading = "lazy", fetchPriority = "auto", }: CollectionCardProps) { const image = collection.image ?? collection.products.nodes[0]?.featuredImage; const alt = collection.image?.altText ?? collection.title; return (
{image ? ( {alt} ) : null}

{collection.title}

); }