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
This commit is contained in:
Unchained
2026-03-30 11:55:21 +02:00
parent 3accf4c244
commit ba4da3287d
2 changed files with 162 additions and 6 deletions

View File

@@ -1,4 +1,3 @@
import Script from 'next/script';
import { SchemaType } from '@/lib/seo/schema/types';
interface JsonLdProps {
@@ -6,11 +5,11 @@ interface JsonLdProps {
}
/**
* React component to render JSON-LD schema markup
* Uses Next.js Script component for proper loading
* 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 component with JSON-LD
* @returns Script tag with JSON-LD
* @example
* <JsonLd data={productSchema} />
* <JsonLd data={[productSchema, breadcrumbSchema]} />
@@ -22,11 +21,10 @@ export function JsonLd({ data }: JsonLdProps) {
return (
<>
{schemas.map((schema, index) => (
<Script
<script
key={index}
id={`json-ld-${index}`}
type="application/ld+json"
strategy="afterInteractive"
dangerouslySetInnerHTML={{
__html: JSON.stringify(schema),
}}