// 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 (
<>