Skip to content

Commit

Permalink
Use themeConfig for switcher configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
jlvandenhout authored and Dr-Electron committed Sep 23, 2023
1 parent 1be8bb1 commit f902ed3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/utils/useSwitcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
Section,
Sidebar,
Item,
Config,
} from '../common/components/Switcher';

export type GlobalPluginData = DocsGlobalPluginData & {
Expand Down Expand Up @@ -79,6 +80,9 @@ function findSidebarItems(
}

export default function useSwitcher(): SwitcherProps {
const {
siteConfig: { themeConfig },
} = useDocusaurusContext();
const plugins = useAllDocsData() as {
[pluginId: string]: GlobalPluginData;
};
Expand All @@ -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) => {
Expand Down
4 changes: 3 additions & 1 deletion switcherConfig.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// @ts-check
import { generateSwitcherConfig } from './src/utils/pluginConfigGenerators';
const {
generateSwitcherConfig,
} = require('./src/utils/pluginConfigGenerators');
const {
buildPluginsConfig,
maintainPluginsConfig,
Expand Down

0 comments on commit f902ed3

Please sign in to comment.