import { ExternalLink, Eye, Heart, MessageCircle, Repeat2, Send } from 'lucide-react' import { formatCount, timeAgo } from '@/lib/format' import type { Post } from '@/lib/types' import CodeBadge from './CodeBadge' const KIND_LABEL: Record = { gift: '赠链', box: '盲盒链接', talk: '讨论' } function sourceLabel(post: Post) { if (post.source === 'telegram') return 'Telegram' if (post.source === 'manual') return '手动添加' return 'X' } /** Render text with links clickable and the gift links highlighted. */ function RichText({ text }: { text: string }) { const parts = text.split(/(https?:\/\/[^\s<>"'))】]+)/g) return (

{parts.map((part, i) => /^https?:\/\//.test(part) ? ( {part.replace(/^https?:\/\//, '').slice(0, 60)} {part.replace(/^https?:\/\//, '').length > 60 ? '…' : ''} ) : ( {part} ) )}

) } export default function PostCard({ post }: { post: Post }) { const media = (post.media || []).filter((m) => m?.url).slice(0, 4) const author = post.author_name || post.author || '未知' const handle = post.source === 'x' && post.author ? `@${post.author}` : null const created = post.created_at ? post.created_at * 1000 : null const codes = post.codes || [] const usable = codes.some((c) => c.usable) const text = post.text || '' return (
{author} {handle && {handle}}
{post.source === 'telegram' && } {sourceLabel(post)} {post.via && post.source === 'telegram' && · {post.via}} {created && · {timeAgo(created)}}
{KIND_LABEL[post.kind] || post.kind} {post.url && ( )}
{text && (
900 ? `${text.slice(0, 900)}…` : text} />
)} {media.length > 0 && (
1 ? 'grid-cols-2' : 'grid-cols-1'}`}> {media.map((m, i) => ( ))}
)} {codes.length > 0 && (
{codes.map((code) => ( ))}
)} {post.source === 'x' && (post.views || post.likes || post.reposts || post.replies) ? ( ) : null}
) }