mirror of
https://github.com/vercel/commerce.git
synced 2025-05-15 05:56:59 +00:00
commit b10e930476d8bbe82f679f3ae8ed44cea733898f Merge: a2c34aa 8531476 Author: Sammii <sammii.h@icloud.com> Date: Wed Apr 24 20:05:09 2024 +0100 Merge pull request #1 from Sammii-HK/feat/restyle-store Feat/restyle store commit 85314765721447f5612cb59b7e668653606e7b7b Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 20:03:12 2024 +0100 responsive design app page carousel commit d5563a7355c2581c29ebf3f11799e1047c0c29dd Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 19:57:47 2024 +0100 updating mobile carousel tile size commit 9976d0d427ea92dab510bface5da9a4e89feabee Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 19:30:07 2024 +0100 updating combox import commit f6a365df8239d26d5feb37cf53d43632ab7c90c4 Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 19:16:08 2024 +0100 styling label price commit cf89e3b0648bb07ed038f872183bd7ecea064df0 Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 19:08:16 2024 +0100 styling accordians and drop downs commit 49f3776ba8894d5fd2aa6b2fea0632f73d6ae093 Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 18:53:14 2024 +0100 updating search and carousel styling commit 7666a25f918a1b53a088dd9240077af5b9013712 Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 18:37:29 2024 +0100 styling product description commit b8280101ad367abfe48aed4fee8ef32ed1fd5d67 Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 18:18:11 2024 +0100 removing `-full` from all rounded elements commit 77480edd79327898aa2c417d34d231db1d593736 Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 18:15:27 2024 +0100 styling cart component commit 3ec0c4d5679b20c66442e5002225cbefe927a13e Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 18:06:53 2024 +0100 updating styling commit efcab218934934edea629406b823fd2b2ac3d193 Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 18:06:43 2024 +0100 updating carousel for correct types commit b14934af8489a6294f1c47a3a41d40d0a7565550 Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 17:57:31 2024 +0100 styling tile commit 0c72e76bad994317d5e39faedfc4aade9a368fe7 Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 17:56:50 2024 +0100 styling label commit ca24a30543ddfbdd345ac405b14e0541a9af1020 Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 17:54:54 2024 +0100 update main app layout for dark view commit 57c1c4cac9a15c2091f652f53f7bb85a6a5b613a Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 17:52:53 2024 +0100 commenting out weight li on description content commit d2f0ac2041b04117e24db0316b470646489aca07 Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 17:52:02 2024 +0100 updating carousel to new style commit 545717006d7f25f36e71b67873d01316aeeafcf9 Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 17:50:55 2024 +0100 updating getAllLiveProducts to handle no param commit 0bf97ecdf69b4f7a4aa00c090e09e613fa1aba8a Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 17:50:39 2024 +0100 styling and adjusting footer & navbar commit 18200b4e848affe01ca9014bdf8ac841ce176114 Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 17:50:00 2024 +0100 updating cart to bag commit 82c30cdda8d38b3111b539a34127155bb82612d5 Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 17:48:32 2024 +0100 SKUs page file check commit e88a45b9d51096b3250062708d5ef1a49138258c Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 17:47:30 2024 +0100 updatibng Prose import path commit 5e81519f983e58758d865b2905f279f34afb67a4 Author: Samantha Kellow <sammii.h@icloud.com> Date: Wed Apr 24 17:45:58 2024 +0100 updating app page metadata commit 9c9a5c035b245d8811a601ba2dd134c5c5f124d7 Author: Samantha Kellow <sammii.h@icloud.com> Date: Tue Apr 23 21:25:05 2024 +0100 making borders muted commit 8a40e08e41a7fdad172e5ffaebb7f791ec66f4e5 Author: Samantha Kellow <sammii.h@icloud.com> Date: Tue Apr 23 20:37:35 2024 +0100 moving ui components to own folder 🧹
146 lines
4.1 KiB
TypeScript
146 lines
4.1 KiB
TypeScript
import type { Metadata } from 'next';
|
|
import { notFound } from 'next/navigation';
|
|
import { Suspense } from 'react';
|
|
|
|
import { GridTileImage } from 'components/grid/tile';
|
|
import Footer from 'components/layout/footer';
|
|
import { Gallery } from 'components/product/gallery';
|
|
import { ProductDescription } from 'components/product/product-description';
|
|
import { HIDDEN_PRODUCT_TAG } from 'lib/constants';
|
|
import { getProduct, getProductRecommendations } from 'lib/shopify';
|
|
import { Image } from 'lib/shopify/types';
|
|
import Link from 'next/link';
|
|
|
|
export const runtime = 'edge';
|
|
|
|
export async function generateMetadata({
|
|
params
|
|
}: {
|
|
params: { handle: string };
|
|
}): Promise<Metadata> {
|
|
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();
|
|
|
|
const productJsonLd = {
|
|
'@context': 'https://schema.org',
|
|
'@type': 'Product',
|
|
name: product.title,
|
|
description: product.description,
|
|
image: product.featuredImage.url,
|
|
offers: {
|
|
'@type': 'AggregateOffer',
|
|
availability: product.availableForSale
|
|
? 'https://schema.org/InStock'
|
|
: 'https://schema.org/OutOfStock',
|
|
priceCurrency: product.priceRange.minVariantPrice.currencyCode,
|
|
highPrice: product.priceRange.maxVariantPrice.amount,
|
|
lowPrice: product.priceRange.minVariantPrice.amount
|
|
}
|
|
};
|
|
|
|
return (
|
|
<>
|
|
<script
|
|
type="application/ld+json"
|
|
dangerouslySetInnerHTML={{
|
|
__html: JSON.stringify(productJsonLd)
|
|
}}
|
|
/>
|
|
<div className="mx-auto max-w-screen-2xl px-4">
|
|
<div className="rounded-lg border border-neutral-900 p-8 px-4 dark:border-neutral-800 dark:bg-black md:p-12 lg:grid lg:grid-cols-6">
|
|
<div className="lg:col-span-3 flex justify-center">
|
|
<Gallery
|
|
images={product.images.map((image: Image) => ({
|
|
src: image.url,
|
|
altText: image.altText
|
|
}))}
|
|
/>
|
|
</div>
|
|
|
|
<div className="lg:col-span-3 lg:grid lg:grid-cols-6">
|
|
<div className="pt-6 lg:py-6 lg:col-span-4 lg:col-start-2">
|
|
<ProductDescription product={product} />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<Suspense>
|
|
<RelatedProducts id={product.id} />
|
|
</Suspense>
|
|
</div>
|
|
<Suspense>
|
|
<Footer />
|
|
</Suspense>
|
|
</>
|
|
);
|
|
}
|
|
|
|
async function RelatedProducts({ id }: { id: string }) {
|
|
const relatedProducts = await getProductRecommendations(id);
|
|
|
|
if (!relatedProducts.length) return null;
|
|
|
|
return (
|
|
<div className="py-8">
|
|
<h2 className="mb-4 text-2xl font-bold">Related Products</h2>
|
|
<div className="flex w-full gap-4 overflow-x-auto pt-1">
|
|
{relatedProducts.map((product, i) => {
|
|
return (
|
|
<Link
|
|
key={i}
|
|
className="w-full flex-none min-[475px]:w-1/2 sm:w-1/3 md:w-1/4 lg:w-1/5"
|
|
href={`/products/${product.handle}`}
|
|
>
|
|
<GridTileImage
|
|
alt={product.title}
|
|
label={{
|
|
title: product.title,
|
|
amount: product.priceRange.maxVariantPrice.amount,
|
|
currencyCode: product.priceRange.maxVariantPrice.currencyCode
|
|
}}
|
|
src={product.featuredImage?.url}
|
|
width={600}
|
|
height={600}
|
|
/>
|
|
</Link>
|
|
);
|
|
})}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|