'use client' import Link from 'next/link' import { usePathname } from 'next/navigation' import { useEffect, useState } from 'react' import { AnimatePresence, motion } from 'framer-motion' import { Menu, X } from 'lucide-react' import { NearleLogo } from '@/components/ui/NearleLogo' import { useScrollSpy } from '@/lib/useScrollSpy' type NavItem = { label: string href: string sectionId?: string } const HOME_SECTIONS = [ 'home', 'features', 'map', 'download', 'contact', ] const NAV: NavItem[] = [ { label: 'Home', href: '/', sectionId: 'home' }, { label: 'About', href: '/about' }, { label: 'Communities', href: '/communities', sectionId: 'map' }, { label: 'Businesses', href: '/businesses' }, { label: 'Download', href: '/#download', sectionId: 'download' }, { label: 'Contact', href: '/contact', sectionId: 'contact' }, ] export function Navbar() { const pathname = usePathname() const [scrolled, setScrolled] = useState(false) const [open, setOpen] = useState(false) const activeSection = useScrollSpy(HOME_SECTIONS) useEffect(() => { const onScroll = () => setScrolled(window.scrollY > 60) onScroll() window.addEventListener('scroll', onScroll, { passive: true }) return () => window.removeEventListener('scroll', onScroll) }, []) useEffect(() => { setOpen(false) }, [pathname]) const isActive = (item: NavItem) => { if (item.href.startsWith('/#')) { if (pathname !== '/') return false return activeSection === item.sectionId } if (item.href === '/') { return ( pathname === '/' && (activeSection === 'home' || activeSection === null) ) } return pathname === item.href || pathname.startsWith(item.href + '/') } return (
{open && (
    {NAV.map((item, i) => { const active = isActive(item) return ( {item.label} ) })}
  • Get Ready Now
)}
) }