import { useContext } from "react"; import { PostDetailContext } from "./context/PostDetailContext"; import { motion } from "framer-motion"; import { CalendarIcon, UserCircleIcon, LockClosedIcon, LockOpenIcon, StarIcon, ClockIcon, EyeIcon, ChatBubbleLeftIcon, } from "@heroicons/react/24/outline"; import { format } from "date-fns"; import { useVisitor } from "@nice/client"; import { VisitType } from "@nice/common"; export default function PostHeader() { const { post, user } = useContext(PostDetailContext); const { like } = useVisitor(); function likeThisPost() { if (!post?.liked) { like.mutateAsync({ data: { visitorId: user?.id || null, postId: post.id, type: VisitType.LIKE, }, }); } } return ( {/* Corner Decorations */}
{/* Title Section */}

{post?.title}

{/* First Row - Basic Info */}
{/* Author Info Badge */} {post?.author?.showname || "匿名用户"} {/* Date Info Badge */} {post?.createdAt && ( {format( new Date(post?.createdAt), "yyyy.MM.dd" )} )} {/* Last Updated Badge */} {post?.updatedAt && post.updatedAt !== post.createdAt && ( 更新于:{" "} {format( new Date(post?.updatedAt), "yyyy.MM.dd" )} )} {/* Visibility Status Badge */} {post?.isPublic ? ( ) : ( )} {post?.isPublic ? "公开" : "私信"}
{/* Second Row - Term and Tags */}
{/* Term Badge */} {post?.term?.name && ( {post.term.name} )} {/* Tags Badges */} {post?.meta?.tags && post.meta.tags.length > 0 && ( {post.meta.tags.map((tag, index) => ( #{tag} ))} )}
{/* Content Section */}
{/* Stats Section */} {post?.likes || 0} 有帮助 {post?.views || 0} 浏览 {post?.commentsCount || 0} 回复 ); }