Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/llms-txt-hub / apps/web/components/json-ld.tsx |
| Date | Not specified in source |
| Repository | Janady13/llms-txt-hub |
| Revision | e0f4bf978d4df168369c7601d9c5f5ea89e84377 |
| Branch | main |
| Path or archive member | apps/web/components/json-ld.tsx |
| Original SHA-256 | 0ce0a3a6592031f6ac6bc9c84de358edc8c984b3df8d65eb6424afaff1cf49d6 |
| Git blob SHA | f0437a2353a2f1fd23ba9f6e0f7e9ed2016ca3de |
| Reading-copy SHA-256 | 0ce0a3a6592031f6ac6bc9c84de358edc8c984b3df8d65eb6424afaff1cf49d6 |
Recovered source transcript
Download complete source text ↓25 lines · 0.8 KB
import { headers } from 'next/headers'
interface JsonLdProps {
data: Record<string, any>
}
/**
* Renders JSON-LD structured data in a script tag for search engine consumption.
* Uses dangerouslySetInnerHTML to prevent React from HTML-escaping JSON characters.
* Escapes `<` as `\u003c` to prevent script tag breakout from content-derived fields.
*/
export async function JsonLd({ data }: JsonLdProps) {
const nonce = (await headers()).get('x-nonce') ?? undefined
const safeJson = JSON.stringify(data).replace(/</g, '\\u003c')
return (
<script
type="application/ld+json"
nonce={nonce}
suppressHydrationWarning
// biome-ignore lint/security/noDangerouslySetInnerHtml: JSON-LD requires unescaped JSON; content is sanitized above by escaping < to \u003c
dangerouslySetInnerHTML={{ __html: safeJson }}
/>
)
}