Skip to content

Commit b92d18a

Browse files
farnabazatinux
andauthored
fix(document-driven): page layout detection (#1955)
Co-authored-by: Sébastien Chopin <[email protected]> Co-authored-by: Sébastien Chopin <[email protected]>
1 parent 45b44a6 commit b92d18a

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/runtime/composables/helpers.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const navBottomLink = (link: NavItem): string | undefined => {
1717
*/
1818
const navDirFromPath = (path: string, tree: NavItem[]): NavItem[] | undefined => {
1919
for (const file of tree) {
20-
if (file._path === path && !file._id) { return file.children }
20+
if (file._path === path && !file._id) { return tree }
2121

2222
if (file.children) {
2323
const result = navDirFromPath(path, file.children)
@@ -41,13 +41,17 @@ const navPageFromPath = (path: string, tree: NavItem[]): NavItem | undefined =>
4141
}
4242

4343
/**
44-
* Find a nav field node from a path.
44+
* Find a navigation field node from a path.
4545
*/
4646
const navKeyFromPath = (path: string, key: string, tree: NavItem[]) => {
4747
let value: any
4848

4949
const goDeep = (path: string, tree: NavItem[]) => {
5050
for (const file of tree) {
51+
if (path !== '/' && file._path === '/') {
52+
// Ignore root page
53+
continue
54+
}
5155
if (path?.startsWith(file._path) && file[key]) { value = file[key] }
5256

5357
if (file._path === path) { return }

src/runtime/composables/utils.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const addPrerenderPath = (path: string) => {
4545

4646
export const shouldUseClientDB = () => {
4747
const { experimental } = useRuntimeConfig().content
48-
if (!process.client) { return false }
48+
if (process.server) { return false }
4949
if (experimental.clientDB) { return true }
5050

5151
const query = useRoute().query
@@ -55,6 +55,9 @@ export const shouldUseClientDB = () => {
5555
}
5656
// Enable clientDB when preview mode is enabled
5757
if (query.preview || useCookie('previewToken').value) {
58+
if (process.dev) {
59+
console.warn('[content] Client DB enabled since a preview token is set (either in query or cookie).')
60+
}
5861
return true
5962
}
6063

0 commit comments

Comments
 (0)