Skip to content

Commit

Permalink
fix(navigation): missing composable when navigation is disabled (#1577)
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz committed Oct 19, 2022
1 parent 77a4a00 commit 667e730
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,8 @@ export default defineNuxtModule<ModuleOptions>({
handler: resolveRuntimeModule('./server/api/navigation')
})
})
} else {
addImports({ name: 'navigationDisabled', as: 'fetchContentNavigation', from: resolveRuntimeModule('./composables/utils') })
}

// Register highlighter
Expand Down
11 changes: 11 additions & 0 deletions src/runtime/composables/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ export const useContentDisabled = () => {
throw new Error('useContent is only accessible when you are using `documentDriven` mode.')
}

export const navigationDisabled = () => {
// Console warnings
// eslint-disable-next-line no-console
console.warn('Navigation is only accessible when you enable it in module options.')
// eslint-disable-next-line no-console
console.warn('Learn more by visiting: https://content.nuxtjs.org/api/configuration#navigation')

// Break app
throw new Error('Navigation is only accessible when you enable it in module options.')
}

export const addPrerenderPath = (path: string) => {
const event = useRequestEvent()
event.res.setHeader(
Expand Down

0 comments on commit 667e730

Please sign in to comment.