import useBaseUrl from '@docusaurus/useBaseUrl'; import { useLocation } from '@docusaurus/router'; import DropdownNavbarItem from '@theme/NavbarItem/DropdownNavbarItem'; import styles from './DocsDropdown.module.css'; type Section = 'genai' | 'ml' | 'default'; interface DocsDropdownProps { mobile?: boolean; position?: 'left' | 'right'; items: any[]; label?: string; [key: string]: any; } export default function DocsDropdown({ mobile, items: configItems, label: configLabel, ...props }: DocsDropdownProps): JSX.Element { const location = useLocation(); const getCurrentSection = (): Section => { const path = location.pathname; const genaiPath = useBaseUrl('/genai'); const mlPath = useBaseUrl('/ml'); if (path.startsWith(genaiPath)) { return 'genai'; } else if (path.startsWith(mlPath)) { return 'ml'; } return 'default'; }; const currentSection = getCurrentSection(); const getLabel = (): JSX.Element => { let color; let text = configLabel || 'Documentation'; if (currentSection === 'genai') { color = 'var(--genai-color-primary)'; text = 'LLMs & Agents'; } else if (currentSection === 'ml') { color = 'var(--ml-color-primary)'; text = 'Machine Learning'; } return (
{color && (
)} {text}
); }; const enhancedItems = configItems.map((item) => { if (item.docsPluginId === 'classic-ml') { return { ...item, label: (
{item.label}
), }; } else if (item.docsPluginId === 'genai') { return { ...item, label: (
{item.label}
), }; } return item; }); return ( ); }