diff --git a/CLAUDE.md b/CLAUDE.md index 30ed931..b4a5373 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -137,7 +137,7 @@ The site implements **comprehensive JSON-LD schemas** across three layers: - `layouts/partials/about.html` — About section with feature cards from `site.yml` - `layouts/partials/sponsors-home.html` — Homepage sponsor logos by tier - `layouts/partials/venue-home.html` — Venue showcase -- `layouts/partials/tickets.html` — Tito ticket widget; the `js.tito.io` script is loaded here only, not site-wide +- `layouts/partials/tickets.html` — Tito ticket widget. The `js.tito.io` script is loaded from `head.html` on the homepage only (not site-wide). Tito's script resets the scroll position on `popstate`, so same-page anchor links are handled in `nav.html` with `pushState` - `layouts/partials/tito-data.html` — Fetches ticket names, prices and sale state from Tito at build time (use with `partialCached`) - `layouts/partials/stats.html` — Animated statistics counters - `layouts/partials/keynotes.html` — Featured keynote speakers diff --git a/layouts/partials/nav.html b/layouts/partials/nav.html index 4b7ee8b..3a17d32 100644 --- a/layouts/partials/nav.html +++ b/layouts/partials/nav.html @@ -148,4 +148,28 @@ document.addEventListener('touchstart', function(e) { if (!e.target.closest('[data-dropdown]')) closeAllDropdowns(); }); + + // Same-page anchor links (e.g. "/#tickets" clicked on the homepage). + // The Tito widget script runs vue-router in this page: it listens to + // "popstate", which a native fragment navigation fires, and then calls + // window.scrollTo(0, 0), sending the visitor back to the top (Firefox). + // Scroll ourselves and update the URL with pushState, which does not fire + // popstate. + document.addEventListener('click', function(e) { + if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return; + const link = e.target.closest('a[href*="#"]'); + if (!link || link.target || link.origin !== location.origin || link.pathname !== location.pathname || !link.hash) return; + const target = document.getElementById(decodeURIComponent(link.hash.slice(1))); + if (!target) return; + e.preventDefault(); + + // Close the mobile menu if the link was inside it + const mobileMenu = document.getElementById('mobile-menu'); + if (mobileMenu && mobileMenu.contains(link) && !mobileMenu.classList.contains('hidden')) { + document.getElementById('menu-toggle').click(); + } + + target.scrollIntoView({ behavior: 'smooth' }); + if (location.hash !== link.hash) history.pushState(null, '', link.hash); + });