Because theme-common has a direct dependency on plugin-content-docs, it is no longer possible to make a site without ever installing content-docs (previously discussed in #3360). Not really a big deal because the user can still install theme-classic and plugin-content-blog and pretend she never pulls in content-docs transitively, but it's still not desirable.
We have some checks in our codebase about whether docs is enabled:
|
// TODO not ideal, see also "useDocs" |
|
export const isDocsPluginEnabled: boolean = !!useAllDocsData; |
|
const NavbarItemComponents: { |
|
// Not really worth typing, as we pass all props down immediately |
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any |
|
[type in Exclude<Types, undefined>]: () => (props: any) => JSX.Element; |
|
} = { |
|
default: () => DefaultNavbarItem, |
|
localeDropdown: () => LocaleDropdownNavbarItem, |
|
search: () => SearchNavbarItem, |
|
dropdown: () => DropdownNavbarItem, |
|
html: () => HtmlNavbarItem, |
|
|
|
// Need to lazy load these items as we don't know for sure the docs plugin is |
|
// loaded. See https://github.com/facebook/docusaurus/issues/3360 |
|
/* eslint-disable @typescript-eslint/no-var-requires, global-require */ |
|
docsVersion: () => require('@theme/NavbarItem/DocsVersionNavbarItem').default, |
|
docsVersionDropdown: () => |
|
require('@theme/NavbarItem/DocsVersionDropdownNavbarItem').default, |
|
doc: () => require('@theme/NavbarItem/DocNavbarItem').default, |
|
docSidebar: () => require('@theme/NavbarItem/DocSidebarNavbarItem').default, |
|
/* eslint-enable @typescript-eslint/no-var-requires, global-require */ |
|
} as const; |
Because we are now always directly importing these hooks from @docusaurus/plugin-content-docs/client instead of letting the docs plugin register theme aliases, these things always statically exist. We should either remove the checks, or dynamically import content-docs/client everywhere (better IMO in terms of bundle size)
Because
theme-commonhas a direct dependency onplugin-content-docs, it is no longer possible to make a site without ever installingcontent-docs(previously discussed in #3360). Not really a big deal because the user can still installtheme-classicandplugin-content-blogand pretend she never pulls incontent-docstransitively, but it's still not desirable.We have some checks in our codebase about whether docs is enabled:
docusaurus/packages/docusaurus-theme-common/src/utils/docsUtils.tsx
Lines 32 to 33 in c8d6c7e
docusaurus/packages/docusaurus-theme-classic/src/theme/NavbarItem/index.tsx
Lines 18 to 38 in c8d6c7e
Because we are now always directly importing these hooks from
@docusaurus/plugin-content-docs/clientinstead of letting the docs plugin register theme aliases, these things always statically exist. We should either remove the checks, or dynamically importcontent-docs/clienteverywhere (better IMO in terms of bundle size)