feat: support ssrContext.head

Co-Authored-By: Daniel Roe <daniel@roe.dev>
This commit is contained in:
Pooya Parsa 2021-01-20 20:13:28 +01:00
parent 387fa4a278
commit 6e9be0eece

View File

@ -62,11 +62,15 @@ function renderHTML (payload, rendered, ssrContext) {
const state = `<script>window.__NUXT__=${devalue(payload)}</script>` const state = `<script>window.__NUXT__=${devalue(payload)}</script>`
const _html = rendered.html const _html = rendered.html
const { htmlAttrs = '', bodyAttrs = '', headTags = '', headAttrs = '' } =
(ssrContext.head && ssrContext.head()) || {}
return htmlTemplate({ return htmlTemplate({
HTML_ATTRS: '', HTML_ATTRS: htmlAttrs,
HEAD_ATTRS: '', HEAD_ATTRS: headAttrs,
BODY_ATTRS: '', BODY_ATTRS: bodyAttrs,
HEAD: rendered.renderResourceHints() + rendered.renderStyles() + (ssrContext.styles || ''), HEAD: headTags +
rendered.renderResourceHints() + rendered.renderStyles() + (ssrContext.styles || ''),
APP: _html + state + rendered.renderScripts() APP: _html + state + rendered.renderScripts()
}) })
} }