mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-26 21:32:42 +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.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)
|
||||
|
Loading…
Reference in New Issue
Block a user