From d299017b9eabedee6c5165cb1e5169d1382bdab3 Mon Sep 17 00:00:00 2001 From: buttercat1791 Date: Sat, 28 Jun 2025 17:42:47 -0500 Subject: [PATCH] Jump to element via ToC --- .../components/publications/Publication.svelte | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/lib/components/publications/Publication.svelte b/src/lib/components/publications/Publication.svelte index a32bdb9..c5efd96 100644 --- a/src/lib/components/publications/Publication.svelte +++ b/src/lib/components/publications/Publication.svelte @@ -22,6 +22,7 @@ import Interactions from "$components/util/Interactions.svelte"; import type { SveltePublicationTree } from "./svelte_publication_tree.svelte"; import TableOfContents from "./TableOfContents.svelte"; + import { goto } from "$app/navigation"; let { rootAddress, publicationType, indexEvent } = $props<{ rootAddress: string; @@ -33,8 +34,6 @@ // #region Loading - // TODO: Test load handling. - let leaves = $state>([]); let isLoading = $state(false); let isDone = $state(false); @@ -82,7 +81,8 @@ // #endregion - // region Columns visibility + // #region Columns visibility + let currentBlog: null | string = $state(null); let currentBlogEvent: null | NDKEvent = $state(null); const isLeaf = $derived(indexEvent.kind === 30041); @@ -123,6 +123,10 @@ return currentBlog && currentBlogEvent && window.innerWidth < 1140; } + // #endregion + + // #region Lifecycle hooks + onDestroy(() => { // reset visibility publicationColumnVisibility.reset(); @@ -157,6 +161,8 @@ observer.disconnect(); }; }); + + // #endregion @@ -170,6 +176,9 @@ depth={2} onSectionFocused={(address: string) => { publicationTree.setBookmark(address); + goto(`#${address}`, { + replaceState: true, + }); }} />