diff --git a/src/lib/components/Publication.svelte b/src/lib/components/Publication.svelte index 0794cc9..9d79264 100644 --- a/src/lib/components/Publication.svelte +++ b/src/lib/components/Publication.svelte @@ -14,8 +14,28 @@ import Preview from "./Preview.svelte"; import { pharosInstance } from "$lib/parser"; import { page } from "$app/state"; - - let { rootId, publicationType } = $props<{ rootId: string, publicationType: string }>(); + import { ndkInstance } from "$lib/ndk"; + import type { NDKEvent } from "@nostr-dev-kit/ndk"; + + let { rootId, publicationType, indexEvent } = $props<{ + rootId: string, + publicationType: string, + indexEvent: NDKEvent + }>(); + + // Get publication metadata for OpenGraph tags + let title = $derived($pharosInstance.getIndexTitle(rootId) || 'Alexandria Publication'); + let currentUrl = page.url.href; + + // Get image and summary from the event tags if available + // If image unavailable, use the Alexandria default pic. + let image = $derived(indexEvent?.getMatchingTags('image')[0]?.[1] || '/screenshots/old_books.jpg'); + let summary = $derived(indexEvent?.getMatchingTags('summary')[0]?.[1] || ``); + + // Debug: Log the event and its tags + console.log('indexEvent:', indexEvent); + console.log('image tag:', indexEvent?.getMatchingTags('image')); + console.log('summary tag:', indexEvent?.getMatchingTags('summary')); if (rootId !== $pharosInstance.getRootIndexId()) { console.error("Root ID does not match parser root index ID"); @@ -94,6 +114,30 @@ }); + + + {title} + + + + + + + + + {#if image} + + {/if} + + + + + + {#if image} + + {/if} + + {#if showTocButton && !showToc}