fix: anchor link need decode (#719)

This commit is contained in:
rock G 2022-12-06 04:21:37 +08:00 committed by GitHub
parent ff7a56a7ac
commit 3ff06fe033
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -21,7 +21,7 @@ function setupSmoothAnchors() {
aElement.addEventListener("click", clickEvent => {
clickEvent.preventDefault();
const targetId = aElement.getAttribute("href").substring(1),
const targetId = decodeURI(aElement.getAttribute("href").substring(1)),
target = document.getElementById(targetId) as HTMLElement,
offset = target.getBoundingClientRect().top - document.documentElement.getBoundingClientRect().top;