summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Spreitzer <nick@200-ok.com>2020-10-30 12:09:44 -0500
committerGitHub <noreply@github.com>2020-10-30 22:39:44 +0530
commit55107fcfc2d79ee0fd713d33f9775f0af842487f (patch)
treea100914d65b17599612ffc5b80374b63acc46697
parent0a7a5407615e241636c931e56441a5fd8d5b621d (diff)
footer: Fix broken anchor link scrolling (#64)
fixes: Footnotes anchor link hrefs such as `#fn:1` fixes: ToC anchors failing with hrefs having numbers. based-on: https://stackoverflow.com/a/51396346/300212
-rw-r--r--layouts/partials/footer.html4
1 files changed, 2 insertions, 2 deletions
diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html
index b94ace0..f3baf82 100644
--- a/layouts/partials/footer.html
+++ b/layouts/partials/footer.html
@@ -30,8 +30,8 @@
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener("click", function (e) {
e.preventDefault();
-
- document.querySelector(this.getAttribute("href")).scrollIntoView({
+ var id = this.getAttribute("href").substr(1);
+ document.querySelector(`[id='${id}']`).scrollIntoView({
behavior: "smooth"
});
});