I am using the __dangerouslyDisableSanitizersByTagID option but it does not work on a hard refresh / static generation of the HTML from within Nuxt.js.
I did, however, notice it's working when navigating the pages of my site via the router (so client-side only it seems).
Incorrect: Viewing page source (browser view source and running npm run generate) I see something like:
<script data-n-head="ssr" vmid="ldjson-schema" type="application/ld+json">
{"@context":"https://schema.org"}
</script>
Correct: ...navigating the site via Vue router I see (in Chrome dev tools):
<script data-n-head="ssr" vmid="ldjson-schema" type="application/ld+json">
{"@context":"https://schema.org"}
</script>
This certainly feels like a bug to me but I'd be happy to hear if I'm doing anything wrong. I was following the documentation:
https://vue-meta.nuxtjs.org/api/#dangerouslydisablesanitizersbytagid
head() {
return {
meta: metas, // Array of meta objects.
script: scripts, // Array of script objects.
__dangerouslyDisableSanitizersByTagID: {
'ldjson-schema': ['innerHTML'], // Matches the ID I set in the script.
}
}
}
I'm not seeing any console errors in either terminal or the browser.
I did it in the same way and I have the same problem.But then I found this: https://github.com/nuxt/nuxt.js/issues/241#issuecomment-363395895
So, you have to use hid instedof vmid to set tag id.
I did it in the same way and I have the same problem.But then I found this: nuxt/nuxt.js#241 (comment)
So, you have to use
hidinstedofvmidto set tag id.
You are absolutely correct! That worked perfectly.
I guess it's not a bug then but lacking in documentation?
Thank you so much for your reply.
Most helpful comment
I did it in the same way and I have the same problem.But then I found this: https://github.com/nuxt/nuxt.js/issues/241#issuecomment-363395895
So, you have to use
hidinstedofvmidto set tag id.