JSON-LD Structured Data Component (site/json-ld.tsx)

next-ai-draw-io · components/site/json-ld.tsx · typescript · Apache-2.0
ui, crm, fw:react, fw:nextjs, tag:json-ld, tag:metadata

React component that injects JSON-LD structured data into the document head for search engines. Reuse to improve SEO metadata.

// Source: https://github.com/DayuanJiang/next-ai-draw-io | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
/** Structured data for search engines, as a JSON-LD script */
export function JsonLd({ data }: { data: object }) {
    return (
        <script
            type="application/ld+json"
            // "<" escaped, so no text in the data can close the script
            dangerouslySetInnerHTML={{
                __html: JSON.stringify(data).replace(/</g, "\\u003c"),
            }}
        />
    )
}

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key