Browse Source

Init TableOfContents Svelte component

master
buttercat1791 10 months ago
parent
commit
899ee46615
  1. 16
      src/lib/components/TableOfContents.svelte
  2. 24
      src/lib/components/Toc.svelte

16
src/lib/components/TableOfContents.svelte

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
<script lang='ts'>
import type { PublicationTree } from '$lib/data_structures/publication_tree';
import type { TocEntry } from '$lib/data_structures/table_of_contents';
import { getContext } from 'svelte';
let { rootAddress } = $props<{ rootAddress: string }>();
let toc = $state<TocEntry[]>([]);
const publicationTree = getContext('publicationTree') as PublicationTree;
// TODO: Build the table of contents.
// Base hrefs on d-tags for events within the publication.
</script>
<!-- TODO: Add contents. -->

24
src/lib/components/Toc.svelte

@ -1,24 +0,0 @@ @@ -1,24 +0,0 @@
<script lang="ts">
import type { NDKEvent } from '@nostr-dev-kit/ndk';
import {nip19} from 'nostr-tools';
export let notes: NDKEvent[] = [];
// check if notes is empty
if (notes.length === 0) {
console.debug('notes is empty');
}
</script>
<div class="toc">
<h2>Table of contents</h2>
<ul>
{#each notes as note}
<li><a href="#{nip19.noteEncode(note.id)}">{note.getMatchingTags('title')[0][1]}</a></li>
{/each}
</ul>
</div>
<style>
.toc h2 {
text-align: center;
}
</style>
Loading…
Cancel
Save