From 1b02cede07a8a09b49572047fe88875444d9866c Mon Sep 17 00:00:00 2001 From: Ahad Birang Date: Wed, 5 Oct 2022 11:11:32 +0200 Subject: [PATCH 1/2] fix(navigation): missing composable when navigation is disabled --- src/module.ts | 2 ++ src/runtime/composables/utils.ts | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/module.ts b/src/module.ts index c300ba922..a6e0fd9a7 100644 --- a/src/module.ts +++ b/src/module.ts @@ -417,6 +417,8 @@ export default defineNuxtModule({ handler: resolveRuntimeModule('./server/api/navigation') }) }) + } else { + addImports({ name: 'navigationDisabled', as: 'fetchContentNavigation', from: resolveRuntimeModule('./composables/utils') }) } // Register highlighter diff --git a/src/runtime/composables/utils.ts b/src/runtime/composables/utils.ts index 098b0f909..cb33b2a92 100644 --- a/src/runtime/composables/utils.ts +++ b/src/runtime/composables/utils.ts @@ -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 are enabling 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 are enabling it in module options.') +} + export const addPrerenderPath = (path: string) => { const event = useRequestEvent() event.res.setHeader( From ef7bf91392fcbf9cb1af610cf7792a82129d941e Mon Sep 17 00:00:00 2001 From: Ahad Birang Date: Wed, 5 Oct 2022 11:15:43 +0200 Subject: [PATCH 2/2] chore: update message --- src/runtime/composables/utils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/runtime/composables/utils.ts b/src/runtime/composables/utils.ts index cb33b2a92..cee29145e 100644 --- a/src/runtime/composables/utils.ts +++ b/src/runtime/composables/utils.ts @@ -23,12 +23,12 @@ export const useContentDisabled = () => { export const navigationDisabled = () => { // Console warnings // eslint-disable-next-line no-console - console.warn('Navigation is only accessible when you are enabling it in module options.') + 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 are enabling it in module options.') + throw new Error('Navigation is only accessible when you enable it in module options.') } export const addPrerenderPath = (path: string) => {