Nuxt/packages/nuxt3/src/pages/runtime/layout.ts

25 lines
574 B
TypeScript
Raw Normal View History

2021-06-30 16:32:22 +00:00
import { defineComponent, h } from 'vue'
// @ts-ignore
2021-06-30 16:32:22 +00:00
import layouts from '#build/layouts'
export default defineComponent({
props: {
name: {
type: [String, Boolean],
default: 'default'
}
},
setup (props, context) {
return () => {
const layout = props.name
if (!layouts[layout]) {
if (process.dev && layout && layout !== 'default') {
console.warn(`Invalid layout \`${layout}\` selected.`)
}
return context.slots.default()
}
return h(layouts[layout], props, context.slots)
}
}
})