mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-18 06:31:27 +00:00
fix(nitro): add body + body prepended scripts to template (#154)
This commit is contained in:
parent
0346d6e88a
commit
c7328732fb
@ -4,8 +4,10 @@
|
|||||||
{{ HEAD }}
|
{{ HEAD }}
|
||||||
</head>
|
</head>
|
||||||
<body {{ BODY_ATTRS }}>
|
<body {{ BODY_ATTRS }}>
|
||||||
|
{{ BODY_SCRIPTS_PREPEND }}
|
||||||
<div id="__nuxt">{{ APP }}</div>
|
<div id="__nuxt">{{ APP }}</div>
|
||||||
<% if (nuxtOptions.vite && nuxtOptions.dev) { %><script type="module" src="/@vite/client"></script>
|
<% if (nuxtOptions.vite && nuxtOptions.dev) { %><script type="module" src="/@vite/client"></script>
|
||||||
<script type="module" src="/entry.client.mjs"></script><% } %>
|
<script type="module" src="/entry.client.mjs"></script><% } %>
|
||||||
|
{{ BODY_SCRIPTS }}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -84,7 +84,9 @@ function renderHTML (payload, rendered, ssrContext) {
|
|||||||
bodyAttrs: '',
|
bodyAttrs: '',
|
||||||
headAttrs: '',
|
headAttrs: '',
|
||||||
headTags: '',
|
headTags: '',
|
||||||
bodyTags: ''
|
bodyTags: '',
|
||||||
|
bodyScriptsPrepend: '',
|
||||||
|
bodyScripts: ''
|
||||||
}
|
}
|
||||||
|
|
||||||
// @vueuse/head
|
// @vueuse/head
|
||||||
@ -100,21 +102,30 @@ function renderHTML (payload, rendered, ssrContext) {
|
|||||||
})
|
})
|
||||||
meta.htmlAttrs += _meta.htmlAttrs.text()
|
meta.htmlAttrs += _meta.htmlAttrs.text()
|
||||||
meta.headAttrs += _meta.headAttrs.text()
|
meta.headAttrs += _meta.headAttrs.text()
|
||||||
meta.bodyAttrs += _meta.bodyAttrs.text()
|
|
||||||
meta.headTags +=
|
meta.headTags +=
|
||||||
_meta.title.text() + _meta.meta.text() +
|
_meta.title.text() + _meta.meta.text() +
|
||||||
_meta.link.text() + _meta.style.text() +
|
_meta.link.text() + _meta.style.text() +
|
||||||
_meta.script.text() + _meta.noscript.text()
|
_meta.script.text() + _meta.noscript.text()
|
||||||
// TODO: Body prepend/append tags
|
meta.bodyAttrs += _meta.bodyAttrs.text()
|
||||||
|
meta.bodyScriptsPrepend =
|
||||||
|
_meta.meta.text({ pbody: true }) + _meta.link.text({ pbody: true }) +
|
||||||
|
_meta.style.text({ pbody: true }) + _meta.script.text({ pbody: true }) +
|
||||||
|
_meta.noscript.text({ pbody: true })
|
||||||
|
meta.bodyScripts =
|
||||||
|
_meta.meta.text({ body: true }) + _meta.link.text({ body: true }) +
|
||||||
|
_meta.style.text({ body: true }) + _meta.script.text({ body: true }) +
|
||||||
|
_meta.noscript.text({ body: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
return htmlTemplate({
|
return htmlTemplate({
|
||||||
HTML_ATTRS: meta.htmlAttrs,
|
HTML_ATTRS: meta.htmlAttrs,
|
||||||
HEAD_ATTRS: meta.headAttrs,
|
HEAD_ATTRS: meta.headAttrs,
|
||||||
BODY_ATTRS: meta.bodyAttrs,
|
|
||||||
HEAD: meta.headTags +
|
HEAD: meta.headTags +
|
||||||
rendered.renderResourceHints() + rendered.renderStyles() + (ssrContext.styles || ''),
|
rendered.renderResourceHints() + rendered.renderStyles() + (ssrContext.styles || ''),
|
||||||
APP: _html + state + rendered.renderScripts()
|
BODY_ATTRS: meta.bodyAttrs,
|
||||||
|
BODY_SCRIPTS_PREPEND: meta.bodyScriptsPrepend,
|
||||||
|
APP: _html + state + rendered.renderScripts(),
|
||||||
|
BODY_SCRIPTS: meta.bodyScripts
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user