From 9abb6efd73fb53e21838f9fdfbb6a5979fed3220 Mon Sep 17 00:00:00 2001 From: Dejvino Date: Fri, 22 May 2026 18:39:52 +0200 Subject: [PATCH] feat: replace hash-based CV toggle with path-based routing Co-authored-by: aider (openai/qwen3.6) --- index.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/index.php b/index.php index a08ecd8..6b9d045 100644 --- a/index.php +++ b/index.php @@ -315,7 +315,7 @@ $cv_skills = $cvData['skills'] ?? []; const animationDuration = 500; // Matches CSS animation duration (0.5s) const staggerDelay = 200; // Delay between each panel unrolling (ms) - const toggleCV = (show, updateHash = true, animate = true) => { + const toggleCV = (show, updateUrl = true, animate = true) => { const grid = document.querySelector('.bento-grid'); const labelText = document.getElementById('toggle-label-text'); @@ -363,8 +363,9 @@ $cv_skills = $cvData['skills'] ?? []; } } - if (updateHash) { - window.location.hash = show ? 'CV' : ''; + if (updateUrl) { + const newUrl = show ? '/cv' : '/'; + history.pushState({ cv: show }, '', newUrl); } // Keep toggle in sync @@ -373,14 +374,20 @@ $cv_skills = $cvData['skills'] ?? []; }; // Initialize state from URL - const checkHash = (animate = false) => toggleCV(window.location.hash === '#CV', false, animate); + const isCvPath = window.location.pathname.includes('/cv'); + const checkUrl = (animate = false) => toggleCV(isCvPath, false, animate); window.addEventListener('load', () => { - checkHash(false); + checkUrl(false); // Small delay to ensure initial styles are applied before enabling transitions setTimeout(() => document.body.classList.remove('preload'), 20); }); - window.addEventListener('hashchange', () => checkHash(true)); + + // Handle back/forward navigation + window.addEventListener('popstate', () => { + const showCv = window.location.pathname.includes('/cv'); + toggleCV(showCv, false, true); + }); const cvToggleInput = document.getElementById('cv-toggle'); cvToggleInput?.addEventListener('change', (e) => {