diff --git a/src/utils/useSwitcher.ts b/src/utils/useSwitcher.ts index 409a51c18eb..aebf8be11fe 100644 --- a/src/utils/useSwitcher.ts +++ b/src/utils/useSwitcher.ts @@ -13,6 +13,7 @@ import { Section, Sidebar, Item, + Config, } from '../common/components/Switcher'; export type GlobalPluginData = DocsGlobalPluginData & { @@ -79,6 +80,9 @@ function findSidebarItems( } export default function useSwitcher(): SwitcherProps { + const { + siteConfig: { themeConfig }, + } = useDocusaurusContext(); const plugins = useAllDocsData() as { [pluginId: string]: GlobalPluginData; }; @@ -91,6 +95,9 @@ export default function useSwitcher(): SwitcherProps { const config = themeConfig.switcher as Config; if (!config) return { main: sidebarItems }; + const config = themeConfig.switcher as Config; + if (!config) return { main: sidebarItems }; + // Convert the sections and docs configuration into a single // tree structure of sections, subsections, docs, and versions. const configTree = config.sections.map((section) => { diff --git a/switcherConfig.js b/switcherConfig.js index 528b1d6d442..d95111f9ae0 100644 --- a/switcherConfig.js +++ b/switcherConfig.js @@ -1,5 +1,7 @@ // @ts-check -import { generateSwitcherConfig } from './src/utils/pluginConfigGenerators'; +const { + generateSwitcherConfig, +} = require('./src/utils/pluginConfigGenerators'); const { buildPluginsConfig, maintainPluginsConfig,