import Link from "next/link"; import type { PostListItem } from "@/lib/api"; import LikeButton from "./LikeButton"; import Avatar from "./Avatar"; import { IconComment, IconEye } from "./Icons"; function formatTime(dateStr: string) { const d = new Date(dateStr); return `${d.getFullYear()}.${String(d.getMonth() + 1).padStart(2, "0")}.${String( d.getDate() ).padStart(2, "0")}`; } /** * 帖子列表行:头像 + 标题 + 作者元信息 + 统计 + 点赞 * 用于首页/板块页,以细线串联,悬浮浅色反馈 */ export default function PostRow({ post, boardHref, index = 0, compact = false, showViews = true, showLike = true, }: { post: PostListItem; index?: number; boardHref?: boolean; compact?: boolean; showViews?: boolean; showLike?: boolean; }) { return (
{(post.pinned > 0 || post.recommended) && (
{post.pinned > 0 && 置顶} {post.recommended && 推荐}
)}

{post.title}

{post.user.nickname} {boardHref && ( <> · {post.board.name} )} · {formatTime(post.created_at)}
{post.comment_count} {showViews && ( {post.view_count} )} {showLike && ( )}
); }