Browse Source

Update publication page load data handling

master
buttercat1791 11 months ago
parent
commit
c63360d1f0
  1. 3
      src/app.d.ts
  2. 17
      src/routes/publication/+page.svelte
  3. 3
      src/routes/publication/+page.ts

3
src/app.d.ts vendored

@ -13,7 +13,8 @@ declare global { @@ -13,7 +13,8 @@ declare global {
parser?: Pharos;
waitable?: Promise<any>;
publicationType?: string;
publicationRootEvent?: NDKEvent;
indexEvent?: NDKEvent;
url?: URL;
}
// interface Platform {}
}

17
src/routes/publication/+page.svelte

@ -1,28 +1,19 @@ @@ -1,28 +1,19 @@
<script lang="ts">
import Article from "$lib/components/Publication.svelte";
import { TextPlaceholder } from "flowbite-svelte";
import type { PageData } from "./$types";
import type { PageProps } from "./$types";
import { onDestroy, setContext } from "svelte";
import { PublicationTree } from "$lib/data_structures/publication_tree";
import { page } from "$app/stores";
// Extend the PageData type with the properties we need
interface ExtendedPageData extends PageData {
waitable: Promise<any>;
publicationType: string;
indexEvent: NDKEvent;
parser: any;
}
let { data }: PageProps = $props();
const publicationTree = new PublicationTree(data.publicationRootEvent, data.ndk);
const publicationTree = new PublicationTree(data.indexEvent, data.ndk);
setContext('publicationTree', publicationTree);
let { data } = $props<{ data: ExtendedPageData }>();
// Get publication metadata for OpenGraph tags
let title = $derived(data.indexEvent?.getMatchingTags('title')[0]?.[1] || data.parser?.getIndexTitle(data.parser?.getRootIndexId()) || 'Alexandria Publication');
let currentUrl = $page.url.href;
let currentUrl = data.url?.href ?? '';
// Get image and summary from the event tags if available
// If image unavailable, use the Alexandria default pic.

3
src/routes/publication/+page.ts

@ -2,7 +2,7 @@ import { error } from '@sveltejs/kit'; @@ -2,7 +2,7 @@ import { error } from '@sveltejs/kit';
import type { Load } from '@sveltejs/kit';
import type { NDKEvent } from '@nostr-dev-kit/ndk';
import { nip19 } from 'nostr-tools';
import { getActiveRelays } from '$lib/ndk.ts';
import { getActiveRelays } from '$lib/ndk';
/**
* Decodes an naddr identifier and returns a filter object
@ -103,5 +103,6 @@ export const load: Load = async ({ url, parent }: { url: URL; parent: () => Prom @@ -103,5 +103,6 @@ export const load: Load = async ({ url, parent }: { url: URL; parent: () => Prom
waitable: fetchPromise,
publicationType,
indexEvent,
url,
};
};

Loading…
Cancel
Save