web-production-saas-starter/next_b2b_starter/components/seo/jsonld.tsx
2025-12-16 18:54:41 +04:00

20 lines
500 B
TypeScript

import Script from "next/script";
type JsonLdProps = {
data: Record<string, unknown> | Record<string, unknown>[];
id?: string;
};
export function JsonLd({ data, id }: JsonLdProps) {
const json = Array.isArray(data) ? data : [data];
const content =
json.length === 1 ? JSON.stringify(json[0]) : JSON.stringify(json);
return (
<Script
id={id}
type="application/ld+json"
strategy="afterInteractive"
dangerouslySetInnerHTML={{ __html: content }}
/>
);
}