1π
β
I writed fork headβs component of inertia js and change function renderTag in component. And it works.But with bugs
renderTag(node) {
// check specific symbol from node.type
switch (node.type.toString()) {
case 'Symbol(Text)':
case 'Symbol(v-txt)':
return node.children
case 'Symbol()':
case 'Symbol(Comment)':
return ''
// if nothing expected, return a html string
default:
return this.renderTagStart(node) +
(node.children ? this.renderTagChildren(node) : '') +
(!this.isUnaryTag(node) ? `</${node.type}>` : '')
}
}
π€Anton R
0π
Create a new component with :
mounted () {
const myJsonScript = document.createElement('script');
myJsonScript.setAttribute('type', 'application/ld+json');
myJsonScript.setAttribute('src', '...src...');
myJsonScript.setAttribute('id', 'random_id');
document.getElementById('app').appendChild(myJsonScript)
}
beforeDestroy () {
document.getElementById('random_id').remove()
}
Use props for each attributes, then it should be close to your need.
In pure SSR, you can do something like this in template:
{{{ "<script type='application/ld+json' >{'key': " + value + "}</script>" }}}
π€pirs
Source:stackexchange.com