'use client'; import Link from 'next/link'; import { usePathname } from 'next/navigation'; import { useState, useEffect } from 'react'; const LINKS = [ { href: '/', label: '홈' }, { href: '/services/music/samples', label: '샘플' }, { href: '/services/music', label: '팩 상세' }, { href: '/studio', label: '스튜디오' }, { href: '/freelance', label: '외주' }, ]; export default function TopNav() { const pathname = usePathname(); const [open, setOpen] = useState(false); const [scrolled, setScrolled] = useState(false); useEffect(() => { const onScroll = () => setScrolled(window.scrollY > 8); onScroll(); window.addEventListener('scroll', onScroll, { passive: true }); return () => window.removeEventListener('scroll', onScroll); }, []); useEffect(() => { setOpen(false); }, [pathname]); useEffect(() => { if (open) { const prev = document.body.style.overflow; document.body.style.overflow = 'hidden'; return () => { document.body.style.overflow = prev; }; } }, [open]); const isActive = (href: string) => { if (href === '/') return pathname === '/'; if (href === '/services/music') return pathname === '/services/music'; return pathname.startsWith(href); }; return ( <>
{/* 모바일 오버레이 */} {open && (
JSM
{LINKS.map((l) => ( {l.label} ))}
로그인 Try now
)} ); }