'use client'; import { usePathname } from 'next/navigation'; import type { PageMapItem } from 'nextra'; import { normalizePages } from 'nextra/normalize-pages'; import { createContext, useContext, type ReactNode } from 'react'; import { DocsMobileNav } from './docs-mobile-nav'; import { Sidebar } from './sidebar'; type NormalizeResult = ReturnType; const ConfigContext = createContext(null); export function useConfig(): NormalizeResult { const ctx = useContext(ConfigContext); if (!ctx) { throw new Error('useConfig must be used within a ConfigProvider'); } return ctx; } export function ConfigProvider({ pageMap, children, }: { pageMap: PageMapItem[]; children: ReactNode; }) { const pathname = usePathname(); const normalized = normalizePages({ list: pageMap, route: pathname }); return ( {/* Outside the padded container so the bar runs full-bleed, and keyed by route so it re-derives its section list and closes on navigation. */}
{children}
); }