'use client'; import { useState, useEffect } from 'react'; import { cn } from "@/lib/utils"; import { usePathname } from 'next/navigation'; import { Button } from "../../components/ui/button"; import { ScrollArea } from "../../components/ui/scroll-area"; import Link from "next/link"; import { Playlist } from "@/lib/navidrome"; import { ChevronLeft, ChevronRight } from "lucide-react"; interface SidebarProps extends React.HTMLAttributes { playlists: Playlist[]; collapsed?: boolean; onToggle?: () => void; } export function Sidebar({ className, playlists, collapsed = false, onToggle }: SidebarProps) { const pathname = usePathname(); // Define all routes and their active states const routes = { isRoot: pathname === "/", isBrowse: pathname === "/browse", isSearch: pathname === "/search", isQueue: pathname === "/queue", isRadio: pathname === "/radio", isPlaylists: pathname === "/library/playlists", isSongs: pathname === "/library/songs", isArtists: pathname === "/library/artists", isAlbums: pathname === "/library/albums", isHistory: pathname === "/history", isFavorites: pathname === "/favorites", isSettings: pathname === "/settings", // Handle dynamic routes isAlbumPage: pathname.startsWith("/album/"), isArtistPage: pathname.startsWith("/artist/"), isPlaylistPage: pathname.startsWith("/playlist/"), isNewPage: pathname === "/new", }; // Helper function to determine if any sidebar route is active // This prevents highlights on pages not defined in sidebar const isAnySidebarRouteActive = Object.values(routes).some(Boolean); return (
{/* Collapse/Expand Button */}

Discover

Library

); }