// ============================================================================= // Astovia · Shell DE (Nav, Footer, Router) — Deutsch // ============================================================================= const PAGES = [ { id: 'home', label: 'Start', num: '00' }, { id: 'about', label: 'Über uns', num: '01', anchor: 'about' }, { id: 'advisory', label: 'Advisory', num: '02' }, { id: 'interim', label: 'Interim', num: '03' }, { id: 'transformation', label: 'Transformation', num: '04' }, { id: 'contact', label: 'Kontakt', num: '05' }]; const ALL_PAGES = PAGES; const VALID_ROUTES = ['home','about','advisory','interim','transformation','contact','impressum','datenschutz']; function useHashRoute() { const getRaw = () => (window.location.hash || '').replace(/^#\/?/, '').trim(); const get = () => { const h = getRaw(); if (h === 'about') return 'home'; return VALID_ROUTES.includes(h) ? h : 'home'; }; const getSelected = () => { const h = getRaw(); return VALID_ROUTES.includes(h) ? h : 'home'; }; const [route, setRoute] = React.useState(get); const [selected, setSelected] = React.useState(getSelected); const scrollToAbout = () => { requestAnimationFrame(() => { const el = document.getElementById('about'); if (el) { const top = el.getBoundingClientRect().top + window.scrollY - 64; window.scrollTo({ top, behavior: 'smooth' }); } }); }; React.useEffect(() => { const onHash = () => { const raw = getRaw(); setSelected(getSelected()); if (raw === 'about') { setRoute('home'); setTimeout(scrollToAbout, 60); } else { setRoute(get()); window.scrollTo({ top: 0, behavior: 'auto' }); } }; window.addEventListener('hashchange', onHash); return () => window.removeEventListener('hashchange', onHash); }, []); const go = (id) => { if (id === 'about') { if (window.location.hash === '#/about') { scrollToAbout(); } else { window.location.hash = '#/about'; } return; } window.location.hash = '#/' + id; }; return [route, go, selected]; } function Nav({ route, go, selected }) { const active = selected || route; const [open, setOpen] = React.useState(false); React.useEffect(() => {setOpen(false);}, [active]); return ( ); } function Footer({ go }) { return ( ); } Object.assign(window, { PAGES, useHashRoute, Nav, Footer });