import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar' import { buildProfileUrl } from '@/lib/utils' import type { PostData } from '@/types' interface PostPreviewProps { post: PostData /** If set and > 0, shows an amber "+N new" badge on the engagement counts. */ newEngagementCount?: number /** Compact mode: lighter card, smaller avatar, 2-line text clamp, no counts or link. */ compact?: boolean } function formatDate(iso: string): string { try { const d = new Date(iso) if (!iso || isNaN(d.getTime())) return '' return d.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' }) } catch { return '' } } // ── Compact variant ─────────────────────────────────────────────────────────── function PostPreviewCompact({ post }: { post: PostData }) { const displayName = post.author.displayName ?? post.author.handle return (
{displayName.charAt(0).toUpperCase()}

{displayName} @{post.author.handle}

{post.text && (

{post.text}

)}
) } // ── Full variant ────────────────────────────────────────────────────────────── function PostPreviewFull({ post, newEngagementCount, }: { post: PostData newEngagementCount?: number }) { const displayName = post.author.displayName ?? post.author.handle const date = formatDate(post.createdAt) return (
{/* Header row: avatar + author info + link */}
{displayName.charAt(0).toUpperCase()}
{displayName}

@{post.author.handle}{date ? ` · ${date}` : ''}

View on Bluesky ↗
{/* Post text */} {post.text && (

{post.text}

)} {/* Engagement counts */}
{post.likeCount != null && ( )} {post.repostCount != null && ( )} {post.replyCount != null && ( )} {post.quoteCount != null && ( )} {newEngagementCount != null && newEngagementCount > 0 && ( +{newEngagementCount.toLocaleString()} new )}
) } function StatPill({ label, color }: { label: string; color: string }) { return ( {label} ) } export function PostPreview({ post, newEngagementCount, compact }: PostPreviewProps) { if (compact) return return }