Clone of salehkargar.ir as a Next.js site with localized pages, SEO, and product gallery. Co-authored-by: Cursor <cursoragent@cursor.com>
106 lines
2.6 KiB
TypeScript
106 lines
2.6 KiB
TypeScript
import { siteConfig } from "@/data/seo";
|
|
|
|
type JsonLdProps = {
|
|
data: Record<string, unknown> | Record<string, unknown>[];
|
|
};
|
|
|
|
export default function JsonLd({ data }: JsonLdProps) {
|
|
return (
|
|
<script
|
|
type="application/ld+json"
|
|
dangerouslySetInnerHTML={{ __html: JSON.stringify(data) }}
|
|
/>
|
|
);
|
|
}
|
|
|
|
export function organizationJsonLd() {
|
|
return {
|
|
"@context": "https://schema.org",
|
|
"@type": "Organization",
|
|
name: siteConfig.name,
|
|
alternateName: siteConfig.nameEn,
|
|
url: siteConfig.url,
|
|
logo: `${siteConfig.url}/images/header/logo1.png`,
|
|
image: `${siteConfig.url}${siteConfig.ogImage}`,
|
|
description: siteConfig.description,
|
|
slogan: siteConfig.slogan,
|
|
telephone: siteConfig.phone,
|
|
address: {
|
|
"@type": "PostalAddress",
|
|
addressLocality: siteConfig.address.locality,
|
|
streetAddress: siteConfig.address.street,
|
|
addressCountry: siteConfig.address.country,
|
|
},
|
|
};
|
|
}
|
|
|
|
export function localBusinessJsonLd() {
|
|
return {
|
|
"@context": "https://schema.org",
|
|
"@type": "LocalBusiness",
|
|
"@id": `${siteConfig.url}/#business`,
|
|
name: siteConfig.name,
|
|
alternateName: siteConfig.nameEn,
|
|
url: siteConfig.url,
|
|
image: `${siteConfig.url}${siteConfig.ogImage}`,
|
|
description: siteConfig.description,
|
|
telephone: siteConfig.phone[0],
|
|
address: {
|
|
"@type": "PostalAddress",
|
|
addressLocality: siteConfig.address.locality,
|
|
streetAddress: siteConfig.address.street,
|
|
addressCountry: siteConfig.address.country,
|
|
},
|
|
areaServed: {
|
|
"@type": "Country",
|
|
name: "Iran",
|
|
},
|
|
};
|
|
}
|
|
|
|
export function productJsonLd(product: {
|
|
title: string;
|
|
description: string;
|
|
image: string;
|
|
price: number;
|
|
slug: string;
|
|
}) {
|
|
return {
|
|
"@context": "https://schema.org",
|
|
"@type": "Product",
|
|
name: product.title,
|
|
description: product.description,
|
|
image: `${siteConfig.url}${product.image}`,
|
|
brand: {
|
|
"@type": "Brand",
|
|
name: siteConfig.shortName,
|
|
},
|
|
offers: {
|
|
"@type": "Offer",
|
|
url: `${siteConfig.url}/products/${product.slug}`,
|
|
priceCurrency: "IRR",
|
|
price: product.price,
|
|
availability: "https://schema.org/InStock",
|
|
seller: {
|
|
"@type": "Organization",
|
|
name: siteConfig.name,
|
|
},
|
|
},
|
|
};
|
|
}
|
|
|
|
export function breadcrumbJsonLd(
|
|
items: { name: string; path: string }[],
|
|
) {
|
|
return {
|
|
"@context": "https://schema.org",
|
|
"@type": "BreadcrumbList",
|
|
itemListElement: items.map((item, index) => ({
|
|
"@type": "ListItem",
|
|
position: index + 1,
|
|
name: item.name,
|
|
item: `${siteConfig.url}${item.path}`,
|
|
})),
|
|
};
|
|
}
|