'use client'; /** * Documentation Sidebar - Production Version * * Based on Variant A with FIXED active states * * Key Improvements: * - Consistent active state styling for both parent and child items * - Clean left border indicator (no background boxes) * - Parent active: purple left border + white text * - Child active: purple left border + white text (NO background) * * Features: * - Thin sidebar with subtle hover states * - Collapsible section groups * - Minimal icons (chevron for expandable items) * - Clean, uncluttered appearance * * Navigation Structure: * - Getting Started * - API Reference (collapsible) * - Guides (collapsible) * - Examples */ import { useState } from 'react'; interface NavItem { label: string; href: string; icon?: string; children?: NavItem[]; } interface DocsSidebarProps { currentPath: string; } const navigationItems: NavItem[] = [ { label: 'Getting Started', href: '/docs', }, { label: 'Image Generation', href: '/docs/generation', }, { label: 'Working with Images', href: '/docs/images', }, { label: 'Live URLs', href: '/docs/live-urls', }, { label: 'Authentication', href: '/docs/authentication', }, { label: 'API Reference', href: '/docs/api', children: [ { label: 'Overview', href: '/docs/api' }, { label: 'Generations', href: '/docs/api/generations' }, { label: 'Images', href: '/docs/api/images' }, { label: 'Flows', href: '/docs/api/flows' }, { label: 'Live Scopes', href: '/docs/api/live-scopes' }, ], }, ]; export const DocsSidebar = ({ currentPath }: DocsSidebarProps) => { const [expandedSections, setExpandedSections] = useState(['API Reference']); const toggleSection = (label: string) => { setExpandedSections((prev) => prev.includes(label) ? prev.filter((item) => item !== label) : [...prev, label] ); }; // Normalize path by removing trailing slash (except for root) const normalizePath = (path: string) => (path.length > 1 && path.endsWith('/') ? path.slice(0, -1) : path); const normalizedCurrentPath = normalizePath(currentPath); const isActive = (href: string) => normalizedCurrentPath === href; const isExpanded = (label: string) => expandedSections.includes(label); return ( ); };