mirror of
https://github.com/yusufipk/OpenFrame.git
synced 2026-09-11 09:36:08 +00:00
fix: emit one json-ld script per schema object
A single ld+json script holding a top-level array crashes naive structured-data consumers (Safari extension content scripts) that read parsed['@context'] without checking for arrays. Emit one script per object so every payload has a top-level @context, and escape < in the root layout like the marketing pages already did. Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
@@ -44,11 +44,19 @@ export default async function MarketingSlugPage({ params }: MarketingSlugPagePro
|
||||
path: `/${page.slug}`,
|
||||
faq: page.faq,
|
||||
});
|
||||
const safeStructuredData = JSON.stringify(structuredData).replace(/</g, '\\u003c');
|
||||
|
||||
return (
|
||||
<>
|
||||
<script type="application/ld+json" dangerouslySetInnerHTML={{ __html: safeStructuredData }} />
|
||||
{/* One script per object: single-object payloads with a top-level
|
||||
@context survive naive JSON-LD consumers that choke on arrays. */}
|
||||
{structuredData.map((data, index) => (
|
||||
<script
|
||||
key={`${String(data['@type'])}-${index}`}
|
||||
type="application/ld+json"
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: JSON.stringify(data).replace(/</g, '\\u003c'),
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
<ComparisonPage page={page} isLoggedIn={Boolean(session?.user)} />
|
||||
</>
|
||||
);
|
||||
|
||||
+11
-4
@@ -120,10 +120,17 @@ export default function RootLayout({
|
||||
suppressHydrationWarning
|
||||
>
|
||||
<body className="antialiased min-h-screen bg-background font-sans">
|
||||
<script
|
||||
type="application/ld+json"
|
||||
dangerouslySetInnerHTML={{ __html: JSON.stringify(structuredData) }}
|
||||
/>
|
||||
{/* One script per object: single-object payloads with a top-level
|
||||
@context survive naive JSON-LD consumers that choke on arrays. */}
|
||||
{structuredData.map((data) => (
|
||||
<script
|
||||
key={String(data['@type'])}
|
||||
type="application/ld+json"
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: JSON.stringify(data).replace(/</g, '\\u003c'),
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
<ThemeProvider attribute="class" defaultTheme="dark" enableSystem disableTransitionOnChange>
|
||||
<svg aria-hidden="true" className="fixed h-0 w-0">
|
||||
<filter id="openframe-noise">
|
||||
|
||||
Reference in New Issue
Block a user