mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +00:00
feat: Handle body scripts from vue-meta
This commit is contained in:
parent
4cfc8f5c49
commit
07eab4c643
@ -45,7 +45,8 @@ export default class MetaRenderer {
|
||||
meta = {
|
||||
HTML_ATTRS: '',
|
||||
BODY_ATTRS: '',
|
||||
HEAD: ''
|
||||
HEAD: '',
|
||||
BODY_SCRIPTS: ''
|
||||
}
|
||||
// Get vue-meta context
|
||||
const m = await this.getMeta(url)
|
||||
@ -55,6 +56,8 @@ export default class MetaRenderer {
|
||||
meta.BODY_ATTRS = m.bodyAttrs.text()
|
||||
// HEAD tags
|
||||
meta.HEAD = m.meta.text() + m.title.text() + m.link.text() + m.style.text() + m.script.text() + m.noscript.text()
|
||||
// BODY_SCRIPTS
|
||||
meta.BODY_SCRIPTS = m.script.text({ body: true })
|
||||
// Resources Hints
|
||||
meta.resourceHints = ''
|
||||
// Resource Hints
|
||||
|
@ -488,8 +488,8 @@ export default class Renderer {
|
||||
const ENV = this.options.env
|
||||
|
||||
if (this.noSSR || spa) {
|
||||
const { HTML_ATTRS, BODY_ATTRS, HEAD, resourceHints } = await this.metaRenderer.render(context)
|
||||
const APP = `<div id="__nuxt">${this.resources.loadingHTML}</div>`
|
||||
const { HTML_ATTRS, BODY_ATTRS, HEAD, BODY_SCRIPTS, resourceHints } = await this.metaRenderer.render(context)
|
||||
const APP = `<div id="__nuxt">${this.resources.loadingHTML}</div>` + BODY_SCRIPTS
|
||||
|
||||
// Detect 404 errors
|
||||
if (url.includes(this.options.build.publicPath) || url.includes('__webpack')) {
|
||||
@ -528,6 +528,7 @@ export default class Renderer {
|
||||
}
|
||||
APP += `<script type="text/javascript">window.__NUXT__=${serialize(context.nuxt, { isJSON: true })};</script>`
|
||||
APP += context.renderScripts()
|
||||
APP += m.script.text({ body: true })
|
||||
|
||||
HEAD += context.renderStyles()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user