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 _html = rendered.html
const { htmlAttrs = '', bodyAttrs = '', headTags = '', headAttrs = '' } =
(ssrContext.head && ssrContext.head()) || {}
return htmlTemplate({
HTML_ATTRS: '',
HEAD_ATTRS: '',
BODY_ATTRS: '',
HEAD: rendered.renderResourceHints() + rendered.renderStyles() + (ssrContext.styles || ''),
HTML_ATTRS: htmlAttrs,
HEAD_ATTRS: headAttrs,
BODY_ATTRS: bodyAttrs,
HEAD: headTags +
rendered.renderResourceHints() + rendered.renderStyles() + (ssrContext.styles || ''),
APP: _html + state + rendered.renderScripts()
})
}