From 0e9d868e7e79a963cbe166d00dbebf95527fdd3e Mon Sep 17 00:00:00 2001 From: Muhammad Salman Date: Sun, 21 Jul 2024 19:45:28 +0500 Subject: [PATCH] append hash to the url when clicking on a sidebar element --- src/views/ArticleView.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/src/views/ArticleView.vue b/src/views/ArticleView.vue index 1dcabf0..1a4390e 100644 --- a/src/views/ArticleView.vue +++ b/src/views/ArticleView.vue @@ -340,6 +340,7 @@ export default defineComponent({ const offset = 53; const element = document.getElementById(headingId); const y = element?.getBoundingClientRect().top; + history.replaceState(null, null, "#" + headingId) window.scrollTo({ top: y ? y + window.scrollY - offset : 0, behavior: "smooth" }); this.isSidebarVisible = false; },