"use client" import { CharacterEntity } from "crossbell" import Link from "next/link" import { useRouter } from "next/navigation" import { memo } from "react" import reactStringReplace from "react-string-replace" import { CharacterFloatCard } from "~/components/common/CharacterFloatCard" import { Titles } from "~/components/common/Titles" import PostCover from "~/components/home/PostCover" import { Avatar } from "~/components/ui/Avatar" import { useDate } from "~/hooks/useDate" import { getSiteLink } from "~/lib/helpers" import { useTranslation } from "~/lib/i18n/client" import { ExpandedNote } from "~/lib/types" import { cn } from "~/lib/utils" const Card = ({ character, post, keyword, comment, createdAt, isPinned, linkPrefix, isBlank, }: { character?: CharacterEntity post: ExpandedNote keyword?: string comment?: string createdAt?: string isPinned?: boolean linkPrefix?: string isBlank?: boolean }) => { const router = useRouter() const { t } = useTranslation("common") const date = useDate() return (
{comment && (
{comment}
)}

{post.metadata?.content?.title}

{!comment && (
{keyword ? reactStringReplace( post.metadata?.content?.summary || "", keyword, (match, i) => ( {match} ), ) : post.metadata?.content?.summary} {post.metadata?.content?.summary && "..."}
)}
{!!post.metadata?.content?.tags?.[1] && ( { e.preventDefault() router.push(`/tag/${post.metadata?.content?.tags?.[1]}`) }} > {post.metadata?.content?.tags?.[1]} )} {post.metadata?.content?.readingTime} {t("min")} {!!post.stat?.viewDetailCount && ( {post.stat?.viewDetailCount} )}
{character && ( <> { e.preventDefault() window.open( `${getSiteLink({ subdomain: character?.handle || "", })}`, ) }} > {character?.metadata?.content?.name || character?.handle} ยท )}
{isPinned && ( {t("Pinned")} )} ) } const Post = ({ post, keyword, isPinned, linkPrefix, isBlank, }: { post: ExpandedNote keyword?: string isPinned?: boolean linkPrefix?: string isBlank?: boolean }) => { let isComment if (post.metadata?.content?.tags?.includes("comment") && post.toNote) { isComment = true } return ( ) } const PostCard = memo(Post) export default PostCard