From 3685845eec6fc508b059c1c8a2f6a61e6312e6dc Mon Sep 17 00:00:00 2001 From: Trock Date: Sun, 6 Nov 2022 20:08:12 +0800 Subject: [PATCH] fix: anchor link need decode (cherry picked from commit 8620d43c77cf8b8ae15907f223b07848a926c9fb) --- assets/ts/smoothAnchors.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/ts/smoothAnchors.ts b/assets/ts/smoothAnchors.ts index 46a4a03..16ab6a3 100644 --- a/assets/ts/smoothAnchors.ts +++ b/assets/ts/smoothAnchors.ts @@ -21,8 +21,8 @@ function setupSmoothAnchors() { aElement.addEventListener("click", clickEvent => { clickEvent.preventDefault(); - const targetId = aElement.getAttribute("href").substring(1), - target = document.getElementById(targetId) as HTMLElement, + const targetId = decodeURI(aElement.getAttribute("href").substring(1)), + target = document.getElementById(targetId) as HTMLElement, offset = target.getBoundingClientRect().top - document.documentElement.getBoundingClientRect().top; window.history.pushState({}, "", aElement.getAttribute("href"));