// HOS — House of Sheylas — App entry + hash router function useHashRoute() { const routeFromPath = () => { const path = window.location.pathname.replace(/^\/+|\/+$/g, ''); if (!path) return 'home'; if (path === 'shop') return 'shop'; if (path.startsWith('shop/')) return path; if (path === 'collections') return 'collections'; if (path === 'about') return 'about'; if (path === 'contact') return 'contact'; if (path.startsWith('product/')) return path; return 'home'; }; const routeFromLocation = () => window.location.hash.slice(1) || routeFromPath(); const routeToPath = (route) => { if (!route || route === 'home') return '/'; return `/${route}`; }; const [route, setRoute] = useState(routeFromLocation); useEffect(() => { const shouldNormalizePath = () => window.location.pathname.replace(/\/+$/g, '') === '/claude/index.html'; const onRoute = () => { const r = routeFromLocation(); setRoute(r); if (window.location.hash || shouldNormalizePath()) { window.history.replaceState(null, '', routeToPath(r)); } // Reset scroll on route change window.scrollTo({ top: 0, behavior: 'instant' in window ? 'instant' : 'auto' }); }; const onClick = (event) => { const link = event.target.closest?.('a[href^="#"]'); if (!link) return; const route = link.getAttribute('href').slice(1) || 'home'; event.preventDefault(); setRoute(route); window.history.pushState(null, '', routeToPath(route)); window.scrollTo({ top: 0, behavior: 'instant' in window ? 'instant' : 'auto' }); }; window.addEventListener('hashchange', onRoute); window.addEventListener('popstate', onRoute); document.addEventListener('click', onClick); onRoute(); return () => { window.removeEventListener('hashchange', onRoute); window.removeEventListener('popstate', onRoute); document.removeEventListener('click', onClick); }; }, []); return route; } function HomePage() { return ( <> ); } function StorefrontRouter() { const route = useHashRoute(); const [head, ...rest] = route.split('/'); // Re-run reveal observer on route change (new elements in DOM) useReveal(route); let Page; switch (head) { case 'home': case '': Page = ; break; case 'shop': Page = ; break; case 'collections': Page = ; break; case 'product': Page = ; break; case 'about': Page = ; break; case 'contact': Page = ; break; case 'order': Page = ; break; default: Page = ; } // Wrap in fade-in keyed to route for smooth transitions return
{Page}
; } function Storefront({ route = 'home' }) { const [menuOpen, setMenuOpen] = useState(false); const [dataVersion, setDataVersion] = useState(0); useEffect(() => { const onSiteDataReady = () => setDataVersion(v => v + 1); window.addEventListener('site-data-ready', onSiteDataReady); return () => window.removeEventListener('site-data-ready', onSiteDataReady); }, []); return (