feat: dynamic spa using serverMiddleware

This commit is contained in:
Pooya Parsa 2017-08-05 13:08:21 +04:30
parent 1f4dfa5f44
commit 8b63b64f54
1 changed files with 14 additions and 12 deletions

View File

@ -412,21 +412,23 @@ export default class Renderer extends Tapable {
context.url = url
context.isServer = true
// Basic response if SSR is disabled
if (this.noSSR) {
let APP = '<div id="__nuxt"></div>'
let HEAD = ''
let html = this.resources.spaTemplate({
// Basic response if SSR is disabled or spa data provided
const SPAData = context.spa || (context.res && context.res.spa)
if (this.noSSR || SPAData) {
const data = {
HTML_ATTRS: '',
BODY_ATTRS: '',
HEAD,
APP
})
return {
html
HEAD: '',
APP: <div id="__nuxt"></div>
}
if (SPAData) {
Object.assign(data, SPAData)
}
const html = this.resources.spaTemplate(data)
return { html }
}
// Call renderToString from the bundleRenderer and generate the HTML (will update the context as well)