import Link from "next/link";
import { formatPostDate, type PostSummary } from "@/lib/blog/types";
import { Arrow } from "./ui";
export function PostCard({ post }: { post: PostSummary }) {
  const href = `/post/${encodeURIComponent(post.slug)}/`;
  return (
    <article className="post" data-post>
      <div className="post-meta">
        <span>By {post.author}</span>
        <span>
          <time dateTime={post.publishedAt}>
            {formatPostDate(post.publishedAt)}
          </time>{" "}
          · {post.readingMinutes} min read
        </span>
      </div>
      <h3>
        <Link href={href}>{post.title}</Link>
      </h3>
      <p>{post.excerpt}</p>
      <Link className="text-link" href={href}>
        Read the article
        <Arrow />
      </Link>
    </article>
  );
}
