Skip to content

Commit

Permalink
Adds a basic product JSON-LD schema on product details page. (#1016)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhushanaj committed May 22, 2023
1 parent 50b4e6c commit 30a0801
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions app/product/[handle]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,31 @@ export default async function ProductPage({ params }: { params: { handle: string

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 (
<div>
<script
type="application/ld+json"
dangerouslySetInnerHTML={{
__html: JSON.stringify(productJsonLd)
}}
/>
<div className="lg:grid lg:grid-cols-6">
<div className="lg:col-span-4">
<Gallery
Expand Down

1 comment on commit 30a0801

@vercel
Copy link

@vercel vercel bot commented on 30a0801 May 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.