home: fix nav active-section at page bottom + exact progress bar; add blog tags to Writing
build-and-deploy / build (push) Failing after 10m38s

- Nav underline highlighted the wrong section at the bottom (the short last
  section never crossed the threshold) — force the last section when scrolled
  to the bottom so Contact lights up instead of Skills
- Scroll-progress bar: compute progress from scrollY/maxScroll so it spans a
  true 0→1 (Motion's default topped out ~0.89 at the bottom)
- Writing section: add blog tag chips linking to /blog/tags/<tag>/
This commit is contained in:
2026-06-29 19:08:17 +10:00
parent 257af5d22e
commit 7c300faec8
2 changed files with 42 additions and 8 deletions
+18 -5
View File
@@ -72,9 +72,15 @@ function run(): void {
* bottom (the progress=1 boundary); the callback maps 0→1 cleanly both ways. */
const bar = document.querySelector<HTMLElement>(".scroll-progress");
if (bar) {
scroll((progress: number) => {
bar.style.transform = `scaleX(${progress})`;
});
// Compute progress straight from scroll position so it reliably spans 0→1
// (Motion's default scroll progress topped out ~0.89 at the true bottom).
const setBar = (): void => {
const max = document.documentElement.scrollHeight - window.innerHeight;
const p = max > 0 ? Math.min(1, Math.max(0, window.scrollY / max)) : 0;
bar.style.transform = `scaleX(${p})`;
};
scroll(setBar);
setBar();
}
/* 5. Nav — animated active-section underline + tactile hover. */
@@ -112,11 +118,18 @@ function initNav(): void {
);
if (sectioned.length) {
const setActive = (): void => {
const line = window.innerHeight * 0.4; // section crossing the upper area is "active"
const vh = window.innerHeight;
const ref = vh * 0.45; // the section whose top has passed this reading line is "active"
let current: HTMLAnchorElement | null = null;
for (const a of sectioned) {
const sec = document.getElementById(a.dataset.navId as string);
if (sec && sec.getBoundingClientRect().top <= line) current = a;
if (sec && sec.getBoundingClientRect().top <= ref) current = a;
}
// At the very bottom the last (often short) section may never push its top
// above the ref line — force it, so Contact lights up at the end instead of
// the highlight getting stuck on the previous section (Skills).
if (window.scrollY + vh >= document.documentElement.scrollHeight - 4) {
current = sectioned[sectioned.length - 1];
}
if (current !== active) {
if (active) under(active, false);