feat(seo): implement dynamic metadata, OpenGraph, and Product JSON-LD structured data [TASK-101]
This commit is contained in:
1 parent
377ebd7257
commit
a8fb4ebd6f
20 files changed
+1050
-7
No files matched your search
@@ -34,7 +34,7 @@ export async function generateMetadata(
|
||||
images: [product.image],
|
||||
url: `/shop/${resolvedParams.slug}`,
|
||||
siteName: "کانینا ایران",
|
||||
type: "music.song", // product type equivalent or website
|
||||
type: "website",
|
||||
},
|
||||
alternates: {
|
||||
canonical: `/shop/${resolvedParams.slug}`,
|
||||
@@ -50,32 +50,71 @@ export default async function ShopProductPage({ params }: { params: Promise<{ sl
|
||||
return <ProductPage productSlug={resolvedParams.slug} />;
|
||||
}
|
||||
|
||||
const jsonLd = {
|
||||
const siteUrl = process.env.NEXT_PUBLIC_SITE_URL || 'https://canina-iran.com';
|
||||
const productUrl = `${siteUrl}/shop/${resolvedParams.slug}`;
|
||||
const priceInRial = product.priceValue * 10;
|
||||
|
||||
const productJsonLd = {
|
||||
'@context': 'https://schema.org',
|
||||
'@type': 'Product',
|
||||
name: product.nameFa || product.name,
|
||||
image: product.image,
|
||||
description: product.shortDescription || product.description,
|
||||
sku: product.artNo,
|
||||
mpn: product.artNo,
|
||||
brand: {
|
||||
'@type': 'Brand',
|
||||
name: 'Canina'
|
||||
name: 'Canina pharma GmbH'
|
||||
},
|
||||
category: product.category,
|
||||
offers: {
|
||||
'@type': 'Offer',
|
||||
url: `https://canina-iran.com/shop/${resolvedParams.slug}`,
|
||||
url: productUrl,
|
||||
priceCurrency: 'IRR',
|
||||
price: product.priceValue * 10, // Assuming priceValue is in Toman, converting to Rial
|
||||
price: priceInRial,
|
||||
availability: 'https://schema.org/InStock',
|
||||
itemCondition: 'https://schema.org/NewCondition'
|
||||
itemCondition: 'https://schema.org/NewCondition',
|
||||
seller: {
|
||||
'@type': 'Organization',
|
||||
name: 'کانینا ایران'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const breadcrumbJsonLd = {
|
||||
'@context': 'https://schema.org',
|
||||
'@type': 'BreadcrumbList',
|
||||
itemListElement: [
|
||||
{
|
||||
'@type': 'ListItem',
|
||||
position: 1,
|
||||
name: 'صفحه اصلی',
|
||||
item: siteUrl
|
||||
},
|
||||
{
|
||||
'@type': 'ListItem',
|
||||
position: 2,
|
||||
name: 'فروشگاه مکملها',
|
||||
item: `${siteUrl}/shop`
|
||||
},
|
||||
{
|
||||
'@type': 'ListItem',
|
||||
position: 3,
|
||||
name: product.nameFa || product.name,
|
||||
item: productUrl
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<script
|
||||
type="application/ld+json"
|
||||
dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
|
||||
dangerouslySetInnerHTML={{ __html: JSON.stringify(productJsonLd) }}
|
||||
/>
|
||||
<script
|
||||
type="application/ld+json"
|
||||
dangerouslySetInnerHTML={{ __html: JSON.stringify(breadcrumbJsonLd) }}
|
||||
/>
|
||||
<ProductPage productSlug={resolvedParams.slug} />
|
||||
</>
|
||||
|
||||
Reference in new issue
Block a user