mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 22:25:12 +00:00
Merge branch 'dev' of github.com:Atinux/nuxt.js into dev
This commit is contained in:
commit
587e3b975c
@ -20,6 +20,8 @@ layoutsKeys.forEach(function (key, i) { %>
|
|||||||
<% }) %>
|
<% }) %>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let resolvedLayouts = {}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
head: <%= JSON.stringify(head) %>,
|
head: <%= JSON.stringify(head) %>,
|
||||||
data: () => ({
|
data: () => ({
|
||||||
@ -37,22 +39,23 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
setLayout (layout) {
|
setLayout (layout) {
|
||||||
if (!layout || !layouts['_' + layout]) layout = 'default'
|
if (!layout || !resolvedLayouts['_' + layout]) layout = 'default'
|
||||||
this.layoutName = layout
|
this.layoutName = layout
|
||||||
let _layout = '_' + layout
|
let _layout = '_' + layout
|
||||||
this.layout = layouts[_layout]
|
this.layout = resolvedLayouts[_layout]
|
||||||
return this.layout
|
return this.layout
|
||||||
},
|
},
|
||||||
loadLayout (layout) {
|
loadLayout (layout) {
|
||||||
if (!layout || !layouts['_' + layout]) layout = 'default'
|
if (!layout || !(layouts['_' + layout] || resolvedLayouts['_' + layout])) layout = 'default'
|
||||||
let _layout = '_' + layout
|
let _layout = '_' + layout
|
||||||
if (typeof layouts[_layout] !== 'function') {
|
if (resolvedLayouts[_layout]) {
|
||||||
return Promise.resolve(layouts[_layout])
|
return Promise.resolve(resolvedLayouts[_layout])
|
||||||
}
|
}
|
||||||
return layouts[_layout]()
|
return layouts[_layout]()
|
||||||
.then((Component) => {
|
.then((Component) => {
|
||||||
layouts[_layout] = Component
|
resolvedLayouts[_layout] = Component
|
||||||
return layouts[_layout]
|
delete layouts[_layout]
|
||||||
|
return resolvedLayouts[_layout]
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
if (this.$nuxt) {
|
if (this.$nuxt) {
|
||||||
|
@ -79,7 +79,7 @@ export default async context => {
|
|||||||
let Components = []
|
let Components = []
|
||||||
try {
|
try {
|
||||||
Components = await Promise.all(getMatchedComponents(router.match(context.url)).map(Component => {
|
Components = await Promise.all(getMatchedComponents(router.match(context.url)).map(Component => {
|
||||||
if (typeof Component !== 'function' || Component.super === Vue) {
|
if (typeof Component !== 'function' || Component.cid) {
|
||||||
return sanitizeComponent(Component)
|
return sanitizeComponent(Component)
|
||||||
}
|
}
|
||||||
return Component().then(Component => sanitizeComponent(Component))
|
return Component().then(Component => sanitizeComponent(Component))
|
||||||
|
@ -20,6 +20,10 @@ export default function ({ isClient }) {
|
|||||||
'stylus': styleLoader.call(this, 'stylus', 'stylus-loader'),
|
'stylus': styleLoader.call(this, 'stylus', 'stylus-loader'),
|
||||||
'styl': styleLoader.call(this, 'stylus', 'stylus-loader')
|
'styl': styleLoader.call(this, 'stylus', 'stylus-loader')
|
||||||
},
|
},
|
||||||
|
template: {
|
||||||
|
// for pug, see https://github.com/vuejs/vue-loader/issues/55
|
||||||
|
doctype: 'html'
|
||||||
|
},
|
||||||
preserveWhitespace: false,
|
preserveWhitespace: false,
|
||||||
extractCSS: extractStyles.call(this)
|
extractCSS: extractStyles.call(this)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user