#Inject script tag ( type="application/ld+json") into the head.

8 messages · Page 1 of 1 (latest)

safe igloo
#

Hi everyone, I am looking to inject script tag ( type="application/ld+json") into the head.

Document Head does not seem to support injecting script tags (As far as I understood it). I am not sure if I should be using partytime, given this is schema tag and not necessarily to be moved to web worker.

Any ideas/ thoughts, on how should I be achieving this ?

timber sinew
#

🙌

#

I simply implemented it in router-head

#

Added this one

// router header
return (
  // ...
  <RouterSchema />
)
#

and RouterSchema returns

<script type="application/ld+json" dangerouslySetInnerHTML={JSON.stringify({
            "@context": "https://schema.org/",
            "@type": "Product",
            "name": product.name,
            "image": product.images,
            "description": product.description,
            "sku": "ANJE23-INSMMA-001",
            "mpn": "ANJE23-INSMMA",
            "brand": {
                "@type": "Brand",
                "name": "Pixeo"
            },
            "aggregateRating": {
                "@type": "AggregateRating",
                "ratingValue": "5",
                "reviewCount": "1"
            },
            "offers": {
                "@type": "AggregateOffer",
                "url": product.url,
                "price": product.price,
                "priceCurrency": "USD",
                "itemCondition": "https://schema.org/NewCondition",
                "availability": "https://schema.org/InStock",
            }
        })} />

you can use context if you want your routes being able to change it

#

I think someone mentioned about injecting script tags – with a PR / package

#

#qwik-contributors message

#

☝️