85 lines
2.0 KiB
TypeScript
85 lines
2.0 KiB
TypeScript
import Script from "next/script";
|
|
|
|
interface JsonLdProps {
|
|
data: Record<string, any>;
|
|
}
|
|
|
|
export function JsonLd({ data }: JsonLdProps) {
|
|
return (
|
|
<Script
|
|
id="json-ld"
|
|
type="application/ld+json"
|
|
dangerouslySetInnerHTML={{
|
|
__html: JSON.stringify(data),
|
|
}}
|
|
strategy="afterInteractive"
|
|
/>
|
|
);
|
|
}
|
|
|
|
// Common schema generators
|
|
export const organizationSchema = {
|
|
"@context": "https://schema.org",
|
|
"@type": "Organization",
|
|
name: "Your Company Name",
|
|
url: process.env.NEXT_PUBLIC_URL || "https://kleap.co",
|
|
logo: `${process.env.NEXT_PUBLIC_URL || "https://kleap.co"}/logo.png`,
|
|
sameAs: [
|
|
"https://twitter.com/yourcompany",
|
|
"https://github.com/yourcompany",
|
|
"https://linkedin.com/company/yourcompany",
|
|
],
|
|
};
|
|
|
|
export const websiteSchema = {
|
|
"@context": "https://schema.org",
|
|
"@type": "WebSite",
|
|
name: "Your SaaS Name",
|
|
url: process.env.NEXT_PUBLIC_URL || "https://kleap.co",
|
|
potentialAction: {
|
|
"@type": "SearchAction",
|
|
target: {
|
|
"@type": "EntryPoint",
|
|
urlTemplate: `${process.env.NEXT_PUBLIC_URL || "https://kleap.co"}/search?q={search_term_string}`,
|
|
},
|
|
"query-input": "required name=search_term_string",
|
|
},
|
|
};
|
|
|
|
export function generateProductSchema(product: {
|
|
name: string;
|
|
description: string;
|
|
price: number;
|
|
currency?: string;
|
|
}) {
|
|
return {
|
|
"@context": "https://schema.org",
|
|
"@type": "Product",
|
|
name: product.name,
|
|
description: product.description,
|
|
offers: {
|
|
"@type": "Offer",
|
|
price: product.price,
|
|
priceCurrency: product.currency || "USD",
|
|
availability: "https://schema.org/InStock",
|
|
},
|
|
};
|
|
}
|
|
|
|
export function generateFAQSchema(
|
|
faqs: Array<{ question: string; answer: string }>,
|
|
) {
|
|
return {
|
|
"@context": "https://schema.org",
|
|
"@type": "FAQPage",
|
|
mainEntity: faqs.map((faq) => ({
|
|
"@type": "Question",
|
|
name: faq.question,
|
|
acceptedAnswer: {
|
|
"@type": "Answer",
|
|
text: faq.answer,
|
|
},
|
|
})),
|
|
};
|
|
}
|