import type { Metadata } from "next"; import { cacheLife, cacheTag } from "next/cache"; import Link from "next/link"; import { CollectionCard } from "@/components/CollectionCard"; import { ProductCard } from "@/components/ProductCard"; import { content } from "@/lib/content"; import { HOME_QUERY } from "@/lib/queries"; import { canonicalUrl } from "@/lib/site"; import { staticStorefrontClient } from "@/lib/storefront-static"; export const metadata: Metadata = { title: "CORE — Discover our latest collection", description: content.home.hero.subtitle, alternates: { canonical: "/" }, openGraph: { title: "CORE — Discover our latest collection", description: content.home.hero.subtitle, type: "website", url: canonicalUrl("/"), }, twitter: { card: "summary_large_image" }, }; /** Home catalog fetch — cached at the data boundary (F2: dynamic root layout * precludes page-level prerender, so the cache-point is the fetch function). */ async function fetchHome() { "use cache"; cacheLife("minutes"); cacheTag("products", "collections"); const { data, errors } = await staticStorefrontClient.graphql(HOME_QUERY); if (errors) { console.error("[hydrogen] Home query failed", errors); } return { featuredProducts: data?.featuredProducts?.nodes ?? [], featuredCollections: data?.featuredCollections?.nodes ?? [], }; } type HomeData = Awaited>; type ProductNode = HomeData["featuredProducts"][number]; type CollectionNode = HomeData["featuredCollections"][number]; export default async function HomePage() { const { featuredProducts, featuredCollections } = await fetchHome(); return ( <> ); } function Hero() { // The hero is the LCP image (notes/home.md): eager + high fetch priority. // Unsplash is a third-party host, so it passes through `shopifyImageUrl` // unchanged — build a width-descriptor srcset directly from its `w=` param // and pair it with `sizes="100vw"` (F12). DPR `srcSetFor` is not used here: // `sizes` is a no-op for 1x/2x descriptors. const heroBaseUrl = "https://images.unsplash.com/photo-1653398597732-37fc919284dd?auto=format&fit=crop&q=80"; const heroSrcSet = `${heroBaseUrl}&w=480 480w, ${heroBaseUrl}&w=1024 1024w, ${heroBaseUrl}&w=2000 2000w`; return (
A white chair beside a white wall

{content.home.hero.heading}

{content.home.hero.subtitle}

{content.home.hero.primaryCta} {content.home.hero.secondaryCta}
); } function BestSellers({ products }: { products: ProductNode[] }) { return (

{content.home.bestSellers}

{content.home.viewAll}
    {products.map((product) => (
  • ))}
); } function ShopByCategory({ collections }: { collections: CollectionNode[] }) { return (

{content.home.shopByCategory}

    {collections.map((collection) => (
  • ))}
); }