From 8e72e8af8f74189d8e53ad690a180f1859470a5f Mon Sep 17 00:00:00 2001 From: Vinta Chen Date: Sun, 3 May 2026 07:56:54 +0800 Subject: [PATCH] feat(website): strip #library-index from URL after All projects click The "All projects" link in the category-page topbar pointed to /#library-index so the browser would scroll to the library section on arrival. The hash stayed in the URL, which looked like an internal anchor state rather than a clean homepage URL. On homepage load, if the hash is #library-index, scroll to the section explicitly and use history.replaceState to drop the hash from the URL. The scrollIntoView call covers the case where the script runs before the browser's native anchor scroll, since replaceState removes the hash the browser would have used. --- website/static/main.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/website/static/main.js b/website/static/main.js index b8d35337..0cb0e1f6 100644 --- a/website/static/main.js +++ b/website/static/main.js @@ -59,6 +59,19 @@ document.querySelectorAll("[data-scroll-to]").forEach(function (link) { }); }); +// Land at #library-index without leaving the hash in the URL +if (window.location.hash === "#library-index") { + const target = document.getElementById("library-index"); + if (target) { + target.scrollIntoView(); + } + history.replaceState( + null, + "", + window.location.pathname + window.location.search, + ); +} + // Pause hero animations when scrolled out of view (function () { const hero = document.querySelector(".hero");