Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(navigation): missing composable when navigation is disabled #1577

Merged
merged 2 commits into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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