Skip to content

Commit 078043c

Browse files
Tahulfarnabaz
authored andcommitted
fix(document-driven): update documentDriven feature (#1294)
1 parent fcd9153 commit 078043c

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

src/runtime/plugins/documentDriven.ts

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { RouteLocationNormalized, RouteLocationNormalizedLoaded } from 'vue-router'
22
// @ts-ignore
33
import { useRuntimeConfig, addRouteMiddleware } from '#app'
4+
import { withoutTrailingSlash } from 'ufo'
45
import { NavItem, ParsedContent } from '../types'
56
// @ts-ignore
67
import { defineNuxtPlugin, queryContent, useContentHelpers, useContentState, fetchContentNavigation, useRoute } from '#imports'
@@ -60,7 +61,7 @@ export default defineNuxtPlugin((nuxt) => {
6061
})
6162
.catch((_) => {
6263
// eslint-disable-next-line no-console
63-
console.log('Could not fetch navigation!')
64+
// console.log('Could not fetch navigation!')
6465
})
6566
}
6667

@@ -94,7 +95,7 @@ export default defineNuxtPlugin((nuxt) => {
9495

9596
return queryContent(query)[type]().catch(() => {
9697
// eslint-disable-next-line no-console
97-
console.log(`Could not find globals key: ${key}`)
98+
// console.log(`Could not find globals key: ${key}`)
9899
})
99100
}
100101
)
@@ -128,11 +129,11 @@ export default defineNuxtPlugin((nuxt) => {
128129
}
129130

130131
return queryContent()
131-
.where({ _path: to.path })
132+
.where({ _path: withoutTrailingSlash(to.path) })
132133
.findOne()
133134
.catch(() => {
134135
// eslint-disable-next-line no-console
135-
console.log(`Could not find page: ${to.path}`)
136+
// console.log(`Could not find page: ${to.path}`)
136137
})
137138
}
138139

@@ -156,10 +157,12 @@ export default defineNuxtPlugin((nuxt) => {
156157
})
157158
// Exclude `body` for `surround`
158159
.without(['body'])
159-
.findSurround(to.path)
160+
.findSurround(
161+
withoutTrailingSlash(to.path)
162+
)
160163
.catch(() => {
161164
// eslint-disable-next-line no-console
162-
console.log(`Could not find surrounding pages for: ${to.path}`)
165+
// console.log(`Could not find surrounding pages for: ${to.path}`)
163166
})
164167
}
165168

@@ -174,20 +177,14 @@ export default defineNuxtPlugin((nuxt) => {
174177
]) => {
175178
if (_navigation) {
176179
navigation.value = _navigation
177-
} else {
178-
navigation.value = []
179180
}
180181

181182
if (_globals) {
182183
globals.value = _globals
183-
} else {
184-
globals.value = {}
185184
}
186185

187186
if (_surround) {
188187
surround.value = _surround
189-
} else {
190-
surround.value = []
191188
}
192189

193190
if (_page) {
@@ -196,8 +193,6 @@ export default defineNuxtPlugin((nuxt) => {
196193

197194
// Update values
198195
page.value = _page
199-
} else {
200-
page.value = undefined
201196
}
202197

203198
// Find used layout

0 commit comments

Comments
 (0)