2026-07-08 17:29:56 +00:00
|
|
|
<script lang="ts">
|
|
|
|
|
import type {ComponentProps} from "svelte"
|
2026-07-28 16:16:26 +00:00
|
|
|
import {Pin} from "@welshman/domain"
|
2026-07-08 17:29:56 +00:00
|
|
|
import Badge from "@lib/components/Badge.svelte"
|
|
|
|
|
import Content from "@app/components/Content.svelte"
|
|
|
|
|
import PinContentEvent from "@app/components/PinContentEvent.svelte"
|
2026-07-28 16:16:26 +00:00
|
|
|
import {reader} from "@app/core"
|
|
|
|
|
import {pinToReference} from "@app/pinboards"
|
2026-07-08 17:29:56 +00:00
|
|
|
|
|
|
|
|
const props: ComponentProps<typeof Content> = $props()
|
|
|
|
|
|
2026-08-22 20:12:11 +00:00
|
|
|
const loadPin = $derived(reader(Pin)(props.event))
|
2026-07-08 17:29:56 +00:00
|
|
|
</script>
|
|
|
|
|
|
2026-07-28 16:16:26 +00:00
|
|
|
{#await loadPin then pin}
|
|
|
|
|
{@const reference = pin.reference()}
|
|
|
|
|
<div class="flex h-full flex-col gap-2">
|
|
|
|
|
{#if pin.title()}
|
|
|
|
|
<strong class="truncate min-w-0">{pin.title()}</strong>
|
|
|
|
|
{/if}
|
|
|
|
|
{#if pin.content()}
|
|
|
|
|
<Content event={{content: pin.content(), tags: []}} />
|
|
|
|
|
{/if}
|
|
|
|
|
{#if reference?.type === "event"}
|
|
|
|
|
<PinContentEvent value={reference.id} relays={reference.relay ? [reference.relay] : []} />
|
|
|
|
|
{:else if reference?.type === "address"}
|
|
|
|
|
<PinContentEvent
|
|
|
|
|
value={reference.address}
|
|
|
|
|
relays={reference.relay ? [reference.relay] : []} />
|
|
|
|
|
{:else}
|
|
|
|
|
<!-- External references are urls or bech32 entities, both of which Content parses. -->
|
|
|
|
|
<Content event={{content: pinToReference(pin), tags: []}} />
|
|
|
|
|
{/if}
|
|
|
|
|
{#if pin.topics().length > 0}
|
|
|
|
|
<div class="mt-auto flex flex-wrap gap-1">
|
|
|
|
|
{#each pin.topics() as topic (topic)}
|
|
|
|
|
<Badge>#{topic}</Badge>
|
|
|
|
|
{/each}
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
|
|
|
|
{/await}
|