-
Notifications
You must be signed in to change notification settings - Fork 788
/
Copy pathblog-card.tsx
40 lines (38 loc) · 1.42 KB
/
blog-card.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import Link from "next/link";
import BlurImage from "./blur-image";
import { placeholderBlurhash, toDateString } from "@/lib/utils";
import type { SelectPost } from "@/lib/schema";
interface BlogCardProps {
data: Pick<
SelectPost,
"slug" | "image" | "imageBlurhash" | "title" | "description" | "createdAt"
>;
}
export default function BlogCard({ data }: BlogCardProps) {
return (
<Link href={`/${data.slug}`}>
<div className="ease overflow-hidden rounded-2xl border-2 border-stone-100 bg-white shadow-md transition-all duration-200 hover:-translate-y-1 hover:shadow-xl dark:border-stone-800">
<BlurImage
src={data.image!}
alt={data.title ?? "Blog Post"}
width={500}
height={400}
className="h-64 w-full object-cover"
placeholder="blur"
blurDataURL={data.imageBlurhash ?? placeholderBlurhash}
/>
<div className="h-36 border-t border-stone-200 px-5 py-8 dark:border-stone-700 dark:bg-black">
<h3 className="font-title text-xl tracking-wide dark:text-white">
{data.title}
</h3>
<p className="text-md my-2 truncate italic text-stone-600 dark:text-stone-400">
{data.description}
</p>
<p className="my-2 text-sm text-stone-600 dark:text-stone-400">
Published {toDateString(data.createdAt)}
</p>
</div>
</div>
</Link>
);
}