Skip to content

Commit

Permalink
fix(navbar): update hash handling to use replaceState for better navi…
Browse files Browse the repository at this point in the history
…gation
  • Loading branch information
DarthGigi committed Jan 7, 2025
1 parent 3b96539 commit 638e6cf
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/lib/components/Navbar.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<script lang="ts">
import { replaceState } from "$app/navigation";
import { page } from "$app/state";
import { Button, ScrollArea } from "bits-ui";
import { onMount } from "svelte";
Expand Down Expand Up @@ -91,7 +93,10 @@
if (isIntersecting) {
let newHash;
newHash = "#" + element.id;
history.replaceState({}, document.title, newHash);
replaceState(newHash, {
...page,
url: { ...page.url, hash: newHash }
});
for (const link of navBarLinks) {
if (link.hash === newHash) {
activeSection = link.hash.slice(1);
Expand Down

0 comments on commit 638e6cf

Please sign in to comment.