How can I inject json-ld data into my route page?

This is the json I want to inject
{
"@context": "http://schema.org",
"@type": "Product",
"name": "Example Product",
"image": "https://example.com/path/to/image.jpg",
"description": "A detailed description of the product.",
"sku": "SKU12345",
"brand": {
"@type": "Brand",
"name": "Brand Name"
},
"offers": {
"@type": "Offer",
"priceCurrency": "USD",
"price": "100.00",
"itemCondition": "http://schema.org/NewCondition",
"availability": "http://schema.org/InStock",
"seller": {
"@type": "Organization",
"name": "Example.com"
}
}
}
{
"@context": "http://schema.org",
"@type": "Product",
"name": "Example Product",
"image": "https://example.com/path/to/image.jpg",
"description": "A detailed description of the product.",
"sku": "SKU12345",
"brand": {
"@type": "Brand",
"name": "Brand Name"
},
"offers": {
"@type": "Offer",
"priceCurrency": "USD",
"price": "100.00",
"itemCondition": "http://schema.org/NewCondition",
"availability": "http://schema.org/InStock",
"seller": {
"@type": "Organization",
"name": "Example.com"
}
}
}
1 Reply
peerreynders
peerreynders3mo ago
If I understand the question, use a JSX <script> element and use the textContent prop. https://playground.solidjs.com/anonymous/47873fec-f47d-44d6-b2f0-05d1d29127ed If you need it on the page layout level you could use it's RouteSectionProps location prop to map each route to a specific json-ld document. If you require collocation have the route page put it in a context so the page layout can pick it up.
Solid Playground
Quickly discover what the solid compiler will generate from your JSX template
GitHub
solid-router/src/types.ts at 3cd2fef67fe0b4d8bb3178923be32d541d56ec...
A universal router for Solid inspired by Ember and React Router - solidjs/solid-router