fix: weiße Seite bei Zurück-Navigation (bfcache) + Dock-Active-Match auf Pfadsegment

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Leon TonhäuserandClaude Fable 5 committed 2026-06-12 13:01:29 +02:00
1 parent 1efd81846d
commit 40fccf2eeb
1 file changed
+15 -5
+15 -5
View File
@@ -66,6 +66,12 @@
setTimeout(function () { window.location.href = ziel; }, 320);
});
/* Zurück-Navigation: der Back-Forward-Cache stellt die Seite im
ausgeblendeten Zustand (seite-ausgang) wieder her → wieder einblenden */
window.addEventListener("pageshow", function (e) {
if (e.persisted) document.body.classList.remove("seite-ausgang");
});
/* ---------- 3) Scroll-Einblenden ---------- */
var elemente = document.querySelectorAll(".einblenden");
if (elemente.length && "IntersectionObserver" in window && !reduce) {
@@ -83,14 +89,18 @@
}
/* ---------- 4a) Dock-Active-State ---------- */
/* decodeURIComponent: Umlaut-URLs (über-mich) kommen prozent-kodiert an */
var pfad = decodeURIComponent(window.location.pathname).replace(/\/index\.html$/, "/");
/* decodeURIComponent: Umlaut-URLs (über-mich) kommen prozent-kodiert an.
Vergleich nur über das letzte Pfadsegment – ein Teilstring-Vergleich
würde z. B. am GitLab-Projektpfad /portfolio-photo/ fälschlich matchen. */
var pfad = decodeURIComponent(window.location.pathname);
var seite = pfad.replace(/\/$/, "").split("/").pop()
.replace(/\.html$/, "").replace(/^index$/, "");
var dockLinks = document.querySelectorAll(".dock-links a");
dockLinks.forEach(function (a) {
var hp = a.getAttribute("href") || "";
var norm = hp.replace(/^\.\//, "/").replace(/\/$/, "");
var aktuell = pfad.replace(/\/$/, "");
if (norm && aktuell.indexOf(norm) !== -1 && norm !== "/") {
if (/^(mailto:|tel:|https?:|#)/i.test(hp)) return;
var ziel = hp.replace(/\/$/, "").split("/").pop().replace(/\.html$/, "");
if (ziel && seite === ziel) {
a.setAttribute("aria-current", "page");
}
});