|
|
|
@ -8,6 +8,7 @@ |
|
|
|
import type { NDKEvent } from '$lib/utils/nostrUtils'; |
|
|
|
import type { NDKEvent } from '$lib/utils/nostrUtils'; |
|
|
|
import { getMatchingTags } from '$lib/utils/nostrUtils'; |
|
|
|
import { getMatchingTags } from '$lib/utils/nostrUtils'; |
|
|
|
import ProfileHeader from "$components/cards/ProfileHeader.svelte"; |
|
|
|
import ProfileHeader from "$components/cards/ProfileHeader.svelte"; |
|
|
|
|
|
|
|
import { getUserMetadata } from "$lib/utils/nostrUtils"; |
|
|
|
|
|
|
|
|
|
|
|
const { event, profile = null, searchValue = null } = $props<{ |
|
|
|
const { event, profile = null, searchValue = null } = $props<{ |
|
|
|
event: NDKEvent; |
|
|
|
event: NDKEvent; |
|
|
|
@ -27,6 +28,7 @@ |
|
|
|
let showFullContent = $state(false); |
|
|
|
let showFullContent = $state(false); |
|
|
|
let parsedContent = $state(''); |
|
|
|
let parsedContent = $state(''); |
|
|
|
let contentPreview = $state(''); |
|
|
|
let contentPreview = $state(''); |
|
|
|
|
|
|
|
let authorDisplayName = $state<string | undefined>(undefined); |
|
|
|
|
|
|
|
|
|
|
|
function getEventTitle(event: NDKEvent): string { |
|
|
|
function getEventTitle(event: NDKEvent): string { |
|
|
|
return getMatchingTags(event, 'title')[0]?.[1] || 'Untitled'; |
|
|
|
return getMatchingTags(event, 'title')[0]?.[1] || 'Untitled'; |
|
|
|
@ -65,6 +67,16 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$effect(() => { |
|
|
|
|
|
|
|
if (event?.pubkey) { |
|
|
|
|
|
|
|
getUserMetadata(toNpub(event.pubkey) as string).then(profile => { |
|
|
|
|
|
|
|
authorDisplayName = profile.displayName || (profile as any).display_name || profile.name || event.pubkey; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
authorDisplayName = undefined; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// --- Identifier helpers --- |
|
|
|
// --- Identifier helpers --- |
|
|
|
function getIdentifiers(event: NDKEvent, profile: any): { label: string, value: string, link?: string }[] { |
|
|
|
function getIdentifiers(event: NDKEvent, profile: any): { label: string, value: string, link?: string }[] { |
|
|
|
const ids: { label: string, value: string, link?: string }[] = []; |
|
|
|
const ids: { label: string, value: string, link?: string }[] = []; |
|
|
|
@ -109,9 +121,13 @@ |
|
|
|
|
|
|
|
|
|
|
|
<div class="flex items-center space-x-2"> |
|
|
|
<div class="flex items-center space-x-2"> |
|
|
|
{#if toNpub(event.pubkey)} |
|
|
|
{#if toNpub(event.pubkey)} |
|
|
|
<span class="text-gray-700 dark:text-gray-300">Author: {@render userBadge(toNpub(event.pubkey) as string, profile?.display_name || event.pubkey)}</span> |
|
|
|
<span class="text-gray-700 dark:text-gray-300"> |
|
|
|
|
|
|
|
Author: {@render userBadge(toNpub(event.pubkey) as string, authorDisplayName)} |
|
|
|
|
|
|
|
</span> |
|
|
|
{:else} |
|
|
|
{:else} |
|
|
|
<span class="text-gray-700 dark:text-gray-300">Author: {profile?.display_name || event.pubkey}</span> |
|
|
|
<span class="text-gray-700 dark:text-gray-300"> |
|
|
|
|
|
|
|
Author: {authorDisplayName} |
|
|
|
|
|
|
|
</span> |
|
|
|
{/if} |
|
|
|
{/if} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
|