Skip to content

Commit

Permalink
append hash to the url when clicking on a sidebar element
Browse files Browse the repository at this point in the history
  • Loading branch information
muhdsalm authored and kbdharun committed Jul 21, 2024
1 parent a8c9d0f commit 0e9d868
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/views/ArticleView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
Expand Down

0 comments on commit 0e9d868

Please sign in to comment.