my-website-v2/frontend/components/PostCard.tsx

35 lines
1.2 KiB
TypeScript
Raw Normal View History

2024-12-02 17:29:45 -06:00
import { convertUtc } from "../lib/convertUtc.ts";
import { truncateString } from "../lib/truncate.ts";
export const PostCard = function PostCard({ post }: { post: Post }) {
return (
<div class="p-6 bg-[#45475a] rounded-lg shadow-md transition-all duration-300 ease-in-out hover:shadow-xl hover:scale-105">
<a href={`${Deno.env.get("BASE_URI_WEB")}/posts/${post.slug}`}>
2024-12-02 17:29:45 -06:00
<h2 class="text-white text-lg font-bold mb-2">{post.title}</h2>
<p class="text-white">
Written by{" "}
<a
class="text-white transition-all duration-300 ease-in-out hover:text-[#74c7ec] hover:drop-shadow-[0_0_10px_rgba(96,165,250,0.7)] hover:scale-110 cursor-pointer"
href={`${Deno.env.get("BASE_URI_WEB")}/authors/${post.author_id}`}
>
{post.first_name} {post.last_name}
</a>{" "}
at {convertUtc(post.created_at)}
</p>
<p class="text-gray-400">{truncateString(post.body, 15)}</p>
</a>
</div>
);
};
export type Post = {
post_id: number;
author_id: number;
first_name: string;
last_name: string;
title: string;
body: string;
created_at: string;
slug: string;
2024-12-02 17:29:45 -06:00
};