Skip to content

Commit 48fc30b

Browse files
committed
fix: support layout from defined vue page in DDM
1 parent 0396252 commit 48fc30b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/runtime/plugins/documentDriven.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@ export default defineNuxtPlugin((nuxt) => {
1414
/**
1515
* Finds a layout value from a cascade of objects.
1616
*/
17-
const findLayout = (page: ParsedContent, navigation: NavItem[], globals: Record<string, any>) => {
17+
const findLayout = (to: RouteLocationNormalized, page: ParsedContent, navigation: NavItem[], globals: Record<string, any>) => {
1818
// Page `layout` key has priority
1919
if (page && page?.layout) { return page.layout }
2020

21+
// Resolve key from .vue page meta
22+
if (to.matched.length && to.matched[0].meta?.layout) { return to.matched[0].meta.layout }
23+
2124
// Resolve key from navigation
2225
if (navigation && page) {
2326
const { navKeyFromPath } = useContentHelpers()
@@ -197,7 +200,7 @@ export default defineNuxtPlugin((nuxt) => {
197200
}
198201

199202
// Find used layout
200-
const layoutName = findLayout(_page, _navigation, _globals)
203+
const layoutName = findLayout(to, _page, _navigation, _globals)
201204

202205
// Prefetch layout component
203206
const layout = layouts[layoutName]

0 commit comments

Comments
 (0)