fix: anchor link need decode (#719)

This commit is contained in:
rock G
2022-12-05 21:21:37 +01:00
committed by GitHub
parent ff7a56a7ac
commit 3ff06fe033
+2 -2
View File
@@ -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"));