diff --git a/src/routes/publication/+page.ts b/src/routes/publication/+page.ts index 3d58b39..7fddcdc 100644 --- a/src/routes/publication/+page.ts +++ b/src/routes/publication/+page.ts @@ -1,11 +1,11 @@ import { error } from '@sveltejs/kit'; -import { NDKRelay, NDKRelaySet, type NDKEvent } from '@nostr-dev-kit/ndk'; +import type { NDKEvent } from '@nostr-dev-kit/ndk'; import type { PageLoad } from './$types'; -import { get } from 'svelte/store'; -import { getActiveRelays, inboxRelays, ndkInstance } from '$lib/ndk'; -import { standardRelays } from '$lib/consts'; +import { getActiveRelays } from '$lib/ndk.ts'; +import { setContext } from 'svelte'; +import { PublicationTree } from '$lib/data_structures/publication_tree.ts'; -export const load: PageLoad = async ({ url, parent }) => { +export const load: PageLoad = async ({ url, parent }: { url: URL; parent: () => Promise }) => { const id = url.searchParams.get('id'); const dTag = url.searchParams.get('d'); @@ -41,6 +41,8 @@ export const load: PageLoad = async ({ url, parent }) => { const publicationType = indexEvent?.getMatchingTags('type')[0]?.[1]; const fetchPromise = parser.fetch(indexEvent); + setContext('publicationTree', new PublicationTree(indexEvent, ndk)); + return { waitable: fetchPromise, publicationType, diff --git a/tsconfig.json b/tsconfig.json index 794b95b..ec41776 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,7 +8,8 @@ "resolveJsonModule": true, "skipLibCheck": true, "sourceMap": true, - "strict": true + "strict": true, + "allowImportingTsExtensions": true } // Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias // diff --git a/vite.config.ts b/vite.config.ts index b9ba52c..d723dc1 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -3,6 +3,12 @@ import { defineConfig } from "vite"; export default defineConfig({ plugins: [sveltekit()], + resolve: { + alias: { + $lib: './src/lib', + $components: './src/components' + } + }, test: { include: ['./tests/unit/**/*.unit-test.js'] }