diff --git a/src/app.d.ts b/src/app.d.ts index 731967b..418205d 100644 --- a/src/app.d.ts +++ b/src/app.d.ts @@ -1,4 +1,8 @@ // See https://kit.svelte.dev/docs/types#app + +import NDK, { NDKEvent } from "@nostr-dev-kit/ndk"; +import Pharos from "./lib/parser.ts"; + // for information about these interfaces declare global { namespace App { @@ -9,6 +13,7 @@ declare global { parser?: Pharos; waitable?: Promise; publicationType?: string; + publicationRootEvent?: NDKEvent; } // interface Platform {} } diff --git a/src/routes/publication/+page.svelte b/src/routes/publication/+page.svelte index dbd673f..b566965 100644 --- a/src/routes/publication/+page.svelte +++ b/src/routes/publication/+page.svelte @@ -2,10 +2,15 @@ import Article from "$lib/components/Publication.svelte"; import { TextPlaceholder } from "flowbite-svelte"; import type { PageData } from "./$types"; - import { onDestroy } from "svelte"; + import { onDestroy, setContext } from "svelte"; + import { PublicationTree } from "$lib/data_structures/publication_tree"; let { data }: { data: PageData } = $props(); + const publicationTree = new PublicationTree(data.publicationRootEvent, data.ndk); + + setContext('publicationTree', publicationTree); + onDestroy(() => data.parser.reset()); diff --git a/src/routes/publication/+page.ts b/src/routes/publication/+page.ts index 286063a..72116ec 100644 --- a/src/routes/publication/+page.ts +++ b/src/routes/publication/+page.ts @@ -102,5 +102,6 @@ export const load: PageLoad = async ({ url, parent }: { url: URL; parent: () => return { waitable: fetchPromise, publicationType, + publicationRootEvent: indexEvent, }; };