diff --git a/packages/docusaurus-plugin-content-docs/src/client/index.ts b/packages/docusaurus-plugin-content-docs/src/client/index.ts index 5d72d657f4ed..32dd0d926133 100644 --- a/packages/docusaurus-plugin-content-docs/src/client/index.ts +++ b/packages/docusaurus-plugin-content-docs/src/client/index.ts @@ -86,10 +86,20 @@ export const useAllDocsData = (): {[pluginId: string]: GlobalPluginData} => } | undefined) ?? StableEmptyObject; -export const useDocsData = (pluginId: string | undefined): GlobalPluginData => - usePluginData('docusaurus-plugin-content-docs', pluginId, { - failfast: true, - }) as GlobalPluginData; +export const useDocsData = (pluginId: string | undefined): GlobalPluginData => { + try { + return usePluginData('docusaurus-plugin-content-docs', pluginId, { + failfast: true, + }) as GlobalPluginData; + } catch (error) { + throw new Error( + `You are using a feature of the Docusaurus docs plugin, but this plugin does not seem to be enabled${ + pluginId === 'Default' ? '' : ` (pluginId=${pluginId}` + }`, + {cause: error as Error}, + ); + } +}; // TODO this feature should be provided by docusaurus core export function useActivePlugin( @@ -143,16 +153,9 @@ export function useActiveVersion( export function useActiveDocContext( pluginId: string | undefined, ): ActiveDocContext { - try { - const data = useDocsData(pluginId); - const {pathname} = useLocation(); - return getActiveDocContext(data, pathname); - } catch (error) { - throw new Error( - 'It seems that you are using a doc plugin feature while the doc plugin seems to be disabled in `docusaurus.config.js`.', - error as Error, - ); - } + const data = useDocsData(pluginId); + const {pathname} = useLocation(); + return getActiveDocContext(data, pathname); } /** * Useful to say "hey, you are not on the latest docs version, please switch" diff --git a/website/docs/blog.mdx b/website/docs/blog.mdx index cd0a3dad9440..1fb3ace11c1b 100644 --- a/website/docs/blog.mdx +++ b/website/docs/blog.mdx @@ -627,7 +627,7 @@ Don't forget to delete the existing homepage at `./src/pages/index.js` or else t :::warning -Don't forget to delete element of type doc in `docusaurus.config.js` in the navbar for example or else Docusaurus will crash. +If you disable the docs plugin, don't forget to delete references to the docs plugin elsewhere in your configuration file. Notably, make sure to remove the docs-related navbar items. :::