Vue-meta: How to use vue-meta with ssr?

Created on 29 Jul 2017  路  10Comments  路  Source: nuxt/vue-meta

Is there any way to use it with createBundleRenderer ? this function outputs the ssr bundle with html and then i'm using this html in .renderToString() function.
So when i'm adding ${meta.text()} to the res.send() my rendered html file becoming weird and not semantic. I mean meta tags are not in < head> and etc.

Thanks.

Most helpful comment

Actually, meta.inject().title.text() render escaped HTML so you can have to use {{{ }}}.

Example: title: '<b>Coucou</b>'

$meta().inject().title.text() => <title data-vue-meta="true">&lt;b&gt;Coucou&lt;/b&gt;</title>

All 10 comments

I found a solution. if anyone interested just add {{{ meta.inject().title.text() }}} and other meta props in template.html

This works, however, the Vue SSR docs discourage the usage of {{{ }}} and warn us of potential XSS attacks:

Use double-mustache (HTML-escaped interpolation) to avoid XSS attacks.

https://ssr.vuejs.org/en/head.html (See "Notes" at the bottom)

I know this, but for now i don't know how to inject it to html. double mustaches just output it as text..

Is there an alternative approach than using {{{ }}}?

@Atinux @declandewet ping

@Atinux - any update on @newenegue's previous comment?

Actually, meta.inject().title.text() render escaped HTML so you can have to use {{{ }}}.

Example: title: '<b>Coucou</b>'

$meta().inject().title.text() => <title data-vue-meta="true">&lt;b&gt;Coucou&lt;/b&gt;</title>

Oh, perfect.

Should we update this in doc?

A PR would be awesome :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hurradieweltgehtunter picture hurradieweltgehtunter  路  4Comments

DRoet picture DRoet  路  9Comments

dystopiandev picture dystopiandev  路  6Comments

dysol picture dysol  路  6Comments

hvalcourtSerdy picture hvalcourtSerdy  路  3Comments