import type { Metadata } from 'next'; import { notFound } from 'next/navigation'; import { Suspense } from 'react'; import Grid from 'components/grid'; import Footer from 'components/layout/footer'; import ProductGridItems from 'components/layout/product-grid-items'; import { AddToCart } from 'components/product/add-to-cart'; import { Gallery } from 'components/product/gallery'; import { VariantSelector } from 'components/product/variant-selector'; import Prose from 'components/prose'; import { HIDDEN_PRODUCT_TAG } from 'lib/constants'; import { getProduct, getProductRecommendations } from 'lib/shopify'; import { Image } from 'lib/shopify/types'; export const runtime = 'edge'; export async function generateMetadata({ params }: { params: { handle: string }; }): Promise { const product = await getProduct(params.handle); if (!product) return notFound(); const { url, width, height, altText: alt } = product.featuredImage || {}; const hide = !product.tags.includes(HIDDEN_PRODUCT_TAG); return { title: product.seo.title || product.title, description: product.seo.description || product.description, robots: { index: hide, follow: hide, googleBot: { index: hide, follow: hide } }, openGraph: url ? { images: [ { url, width, height, alt } ] } : null }; } export default async function ProductPage({ params }: { params: { handle: string } }) { const product = await getProduct(params.handle); if (!product) return notFound(); return (
({ src: image.url, altText: image.altText }))} />
{/* @ts-expect-error Server Component */} {product.descriptionHtml ? ( ) : null}
{/* @ts-expect-error Server Component */} {/* @ts-expect-error Server Component */}
); } async function RelatedProducts({ id }: { id: string }) { const relatedProducts = await getProductRecommendations(id); if (!relatedProducts.length) return null; return (
Related Products
); }