Files
manoon-headless/src/components/seo/JsonLd.tsx
Unchained ba4da3287d fix: JSON-LD schema rendering in SSR
- Remove next/script dependency causing SSR issues
- Use regular script tag for server-side rendering
- Add real SEO verification test that checks rendered output
- All 7/7 SEO checks now passing
2026-03-30 11:55:21 +02:00

38 lines
889 B
TypeScript

import { SchemaType } from '@/lib/seo/schema/types';
interface JsonLdProps {
data: SchemaType | SchemaType[];
}
/**
* Server-safe JSON-LD schema component
* Renders directly to HTML for SSR (no client-side JS needed)
*
* @param data - Single schema object or array of schemas
* @returns Script tag with JSON-LD
* @example
* <JsonLd data={productSchema} />
* <JsonLd data={[productSchema, breadcrumbSchema]} />
*/
export function JsonLd({ data }: JsonLdProps) {
// Handle single schema or array
const schemas = Array.isArray(data) ? data : [data];
return (
<>
{schemas.map((schema, index) => (
<script
key={index}
id={`json-ld-${index}`}
type="application/ld+json"
dangerouslySetInnerHTML={{
__html: JSON.stringify(schema),
}}
/>
))}
</>
);
}
export default JsonLd;