mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-27 13:52:38 +00:00
feat: dynamic spa using serverMiddleware
This commit is contained in:
parent
1f4dfa5f44
commit
8b63b64f54
@ -412,21 +412,23 @@ export default class Renderer extends Tapable {
|
|||||||
context.url = url
|
context.url = url
|
||||||
context.isServer = true
|
context.isServer = true
|
||||||
|
|
||||||
// Basic response if SSR is disabled
|
// Basic response if SSR is disabled or spa data provided
|
||||||
if (this.noSSR) {
|
const SPAData = context.spa || (context.res && context.res.spa)
|
||||||
let APP = '<div id="__nuxt"></div>'
|
if (this.noSSR || SPAData) {
|
||||||
let HEAD = ''
|
const data = {
|
||||||
|
|
||||||
let html = this.resources.spaTemplate({
|
|
||||||
HTML_ATTRS: '',
|
HTML_ATTRS: '',
|
||||||
BODY_ATTRS: '',
|
BODY_ATTRS: '',
|
||||||
HEAD,
|
HEAD: '',
|
||||||
APP
|
APP: <div id="__nuxt"></div>
|
||||||
})
|
|
||||||
|
|
||||||
return {
|
|
||||||
html
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
// Call renderToString from the bundleRenderer and generate the HTML (will update the context as well)
|
||||||
|
Loading…
Reference in New Issue
Block a user