Nuxt.js: How correctly use ld+json scripts

Created on 26 Jul 2017  路  4Comments  路  Source: nuxt/nuxt.js

Hi, I want to use in head() props of page script with ld+json content type. With documentation of vue-meta I set example:

script: [
  { innerHTML: '{ "@context": "http://schema.org" }', type: 'application/ld+json' }
]

but on rendered page I has output with

<script data-n-head="true" type="application/ld+json">{ &quot;@context&quot;: &quot;http://schema.org&quot; }</script>

As you can see, content inside tag was escaped and not valid. How I must set vue-meta for correct usage?

Most helpful comment

@psnoonan yes, you need add a __dangerouslyDisableSanitizers: ['script'], props (docs) to correct insert inner text. As example:
image

All 4 comments

Did you find a solution to this?

@psnoonan yes, you need add a __dangerouslyDisableSanitizers: ['script'], props (docs) to correct insert inner text. As example:
image

@ruslankonev It worked for me by changing "innerHTML" to just "inner"

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jaredreich picture jaredreich  路  3Comments

mikekidder picture mikekidder  路  3Comments

pehbehbeh picture pehbehbeh  路  3Comments

vadimsg picture vadimsg  路  3Comments

nassimbenkirane picture nassimbenkirane  路  3Comments