function Nav() { const [open, setOpen] = React.useState(false); // detect if we're on a sub-page (portfolio.html, case-*.html) → prefix anchors with index.html const isHome = React.useMemo(() => { if (typeof window === 'undefined') return true; const p = window.location.pathname; return p.endsWith('/') || p.endsWith('/index.html') || p === '' || /\/$/.test(p); }, []); const base = isHome ? '' : 'index.html'; const link = (hash) => base + hash; // close mobile menu on hash change / resize to desktop React.useEffect(() => { const close = () => setOpen(false); const onResize = () => { if (window.innerWidth > 880) setOpen(false); }; window.addEventListener('hashchange', close); window.addEventListener('resize', onResize); return () => { window.removeEventListener('hashchange', close); window.removeEventListener('resize', onResize); }; }, []); // lock body scroll while open React.useEffect(() => { document.body.style.overflow = open ? 'hidden' : ''; return () => { document.body.style.overflow = ''; }; }, [open]); React.useEffect(() => { if (window.lucide) lucide.createIcons(); }, [open]); const items = [ { href: link('#problemy'), label: 'Dla kogo' }, { href: link('#pomagam'), label: 'Jak pomagam' }, { href: link('#portfolio'), label: 'Portfolio' }, { href: link('#proces'), label: 'Współpraca' }, { href: link('#omnie'), label: 'O mnie' }, { href: link('#faq'), label: 'FAQ' }, ]; return (
setOpen(false)}>
{items.map((it) => ( setOpen(false)}>{it.label} ))}
setOpen(false)}> Umów darmowy audyt
); } window.Nav = Nav;