2026-08-17 15:42:14 +00:00
|
|
|
<script lang="ts">
|
|
|
|
|
import {formatTimestamp} from "@welshman/lib"
|
|
|
|
|
import type {TrustedEvent} from "@welshman/util"
|
|
|
|
|
import {getAddress} from "@welshman/util"
|
|
|
|
|
import {Article} from "@welshman/domain"
|
|
|
|
|
import Link from "@lib/components/Link.svelte"
|
|
|
|
|
import Content from "@app/components/Content.svelte"
|
|
|
|
|
import ProfileLink from "@app/components/ProfileLink.svelte"
|
|
|
|
|
import ArticleActions from "@app/components/ArticleActions.svelte"
|
2026-09-03 20:13:21 +00:00
|
|
|
import UnreadDot from "@app/components/UnreadDot.svelte"
|
2026-08-29 16:19:01 +00:00
|
|
|
import type {FeedContext} from "@app/feeds"
|
2026-08-17 15:42:14 +00:00
|
|
|
import {reader} from "@app/core"
|
|
|
|
|
import {makeArticlePath} from "@app/routes"
|
|
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
url: string
|
|
|
|
|
event: TrustedEvent
|
2026-08-29 16:19:01 +00:00
|
|
|
context: FeedContext
|
2026-08-17 15:42:14 +00:00
|
|
|
}
|
|
|
|
|
|
2026-08-29 16:19:01 +00:00
|
|
|
const {url, event, context}: Props = $props()
|
2026-08-17 15:42:14 +00:00
|
|
|
|
2026-09-03 20:13:21 +00:00
|
|
|
const path = $derived(makeArticlePath(url, getAddress(event)))
|
2026-08-22 20:12:11 +00:00
|
|
|
const article = $derived(reader(Article)(event))
|
|
|
|
|
const title = $derived(article.title())
|
|
|
|
|
const summary = $derived(article.summary())
|
|
|
|
|
const image = $derived(article.image())
|
2026-08-17 15:42:14 +00:00
|
|
|
</script>
|
|
|
|
|
|
2026-08-22 17:55:06 +00:00
|
|
|
<div data-component="ArticleItem" class="cv relative w-full card card-interactive">
|
|
|
|
|
<!-- An overlay rather than a wrapper: the card carries a profile button and the room and action
|
|
|
|
|
links, and none of those may sit inside an anchor. -->
|
2026-09-03 20:13:21 +00:00
|
|
|
<Link class="absolute inset-0 rounded-2xl" href={path} aria-label={title || "Untitled"} />
|
|
|
|
|
<UnreadDot {path} class="absolute right-3 top-3" />
|
2026-08-22 17:55:06 +00:00
|
|
|
<div class="pointer-events-none relative flex flex-col gap-2">
|
|
|
|
|
{#if image}
|
|
|
|
|
<img src={image} alt="" class="h-40 w-full rounded-2xl object-cover" />
|
|
|
|
|
{/if}
|
|
|
|
|
<div class="flex w-full items-center justify-between gap-2">
|
|
|
|
|
<p class="text-xl">{title || "Untitled"}</p>
|
|
|
|
|
<p class="whitespace-nowrap text-sm opacity-75">
|
|
|
|
|
{formatTimestamp(article.publishedAt())}
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
<Content
|
|
|
|
|
event={{content: summary || event.content, tags: event.tags}}
|
|
|
|
|
{url}
|
|
|
|
|
expandMode="inline"
|
|
|
|
|
minLength={100}
|
|
|
|
|
maxLength={300} />
|
2026-08-31 15:12:54 +00:00
|
|
|
<div class="flex w-full flex-col items-end justify-between gap-2 sm:flex-row">
|
|
|
|
|
<span class="pointer-events-auto whitespace-nowrap py-1 text-sm opacity-75">
|
2026-08-22 17:55:06 +00:00
|
|
|
Written by
|
|
|
|
|
<ProfileLink pubkey={event.pubkey} {url} />
|
|
|
|
|
</span>
|
2026-08-31 15:12:54 +00:00
|
|
|
<div class="pointer-events-auto shrink-0">
|
|
|
|
|
<ArticleActions showRoom showActivity {url} {event} {context} />
|
|
|
|
|
</div>
|
2026-08-22 17:55:06 +00:00
|
|
|
</div>
|
2026-08-17 15:42:14 +00:00
|
|
|
</div>
|
2026-08-22 17:55:06 +00:00
|
|
|
</div>
|