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:
@@ -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),
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user