diff --git a/src/lib/components/publications/Publication.svelte b/src/lib/components/publications/Publication.svelte index 7147de4..2511de0 100644 --- a/src/lib/components/publications/Publication.svelte +++ b/src/lib/components/publications/Publication.svelte @@ -19,9 +19,9 @@ import { publicationColumnVisibility } from "$lib/stores"; import BlogHeader from "$components/cards/BlogHeader.svelte"; import Interactions from "$components/util/Interactions.svelte"; - import TocToggle from "$components/util/TocToggle.svelte"; import { pharosInstance } from '$lib/parser'; import type { SveltePublicationTree } from "./svelte_publication_tree.svelte"; + import TableOfContents from "./TableOfContents.svelte"; let { rootAddress, publicationType, indexEvent } = $props<{ rootAddress: string; @@ -160,7 +160,12 @@ {#if publicationType !== "blog" || !isLeaf} - + { + publicationTree.setBookmark(address); + }} + /> {/if} diff --git a/src/lib/components/publications/TableOfContents.svelte b/src/lib/components/publications/TableOfContents.svelte index 891476a..aadfded 100644 --- a/src/lib/components/publications/TableOfContents.svelte +++ b/src/lib/components/publications/TableOfContents.svelte @@ -1,22 +1,63 @@ - - {#each toc as entry} - {entry.title} + + {#each entries as entry} + +

{entry.title}

+ {#if entry.children.length > 0} + + {/if} +
{/each} -
+ diff --git a/src/routes/publication/+page.svelte b/src/routes/publication/+page.svelte index 7defecf..457d896 100644 --- a/src/routes/publication/+page.svelte +++ b/src/routes/publication/+page.svelte @@ -6,11 +6,18 @@ import Processor from "asciidoctor"; import ArticleNav from "$components/util/ArticleNav.svelte"; import { SveltePublicationTree } from "$lib/components/publications/svelte_publication_tree.svelte"; + import { TableOfContents } from "$lib/components/publications/table_of_contents.svelte"; let { data }: PageProps = $props(); const publicationTree = new SveltePublicationTree(data.indexEvent, data.ndk); + const toc = new TableOfContents( + data.indexEvent.tagAddress(), + publicationTree, + data.url?.pathname ?? "", + ); setContext("publicationTree", publicationTree); + setContext("toc", toc); setContext("asciidoctor", Processor()); // Get publication metadata for OpenGraph tags