import { truncateString } from "../lib/truncate.ts";

export const PostCard = function PostCard({ post }: { post: Post }) {
  return (
    <div class="p-6 bg-gray-700 rounded-lg shadow-md">
      <h2 class="text-grey-900 text-lg font-bold mb-2">{post.title}</h2>
      <p>
        Written by {post.first_name} {post.last_name} at {post.created_at}
      </p>
      <p>{truncateString(post.body, 15)}</p>
    </div>
  );
};

export interface Post {
  post_id: number;
  first_name: string;
  last_name: string;
  title: string;
  body: string;
  created_at: string;
}
