-
Notifications
You must be signed in to change notification settings - Fork 788
/
Copy pathpost-card.tsx
61 lines (59 loc) · 2.32 KB
/
post-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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import BlurImage from "@/components/blur-image";
import type { SelectPost, SelectSite } from "@/lib/schema";
import { placeholderBlurhash, random } from "@/lib/utils";
import { BarChart, ExternalLink } from "lucide-react";
import Link from "next/link";
export default function PostCard({
data,
}: {
data: SelectPost & { site: SelectSite | null };
}) {
const url = `${data.site?.subdomain}.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}/${data.slug}`;
return (
<div className="relative rounded-lg border border-stone-200 pb-10 shadow-md transition-all hover:shadow-xl dark:border-stone-700 dark:hover:border-white">
<Link
href={`/post/${data.id}`}
className="flex flex-col overflow-hidden rounded-lg"
>
<div className="relative h-44 overflow-hidden">
<BlurImage
alt={data.title ?? "Card thumbnail"}
width={500}
height={400}
className="h-full object-cover"
src={data.image ?? "/placeholder.png"}
placeholder="blur"
blurDataURL={data.imageBlurhash ?? placeholderBlurhash}
/>
{!data.published && (
<span className="absolute bottom-2 right-2 rounded-md border border-stone-200 bg-white px-3 py-0.5 text-sm font-medium text-stone-600 shadow-md">
Draft
</span>
)}
</div>
<div className="border-t border-stone-200 p-4 dark:border-stone-700">
<h3 className="my-0 truncate font-cal text-xl font-bold tracking-wide dark:text-white dark:text-white">
{data.title}
</h3>
<p className="mt-2 line-clamp-1 text-sm font-normal leading-snug text-stone-500 dark:text-stone-400">
{data.description}
</p>
</div>
</Link>
<div className="absolute bottom-4 flex w-full px-4">
<a
href={
process.env.NEXT_PUBLIC_VERCEL_ENV
? `https://${url}`
: `http://${data.site?.subdomain}.localhost:3000/${data.slug}`
}
target="_blank"
rel="noreferrer"
className="truncate rounded-md bg-stone-100 px-2 py-1 text-sm font-medium text-stone-600 transition-colors hover:bg-stone-200 dark:bg-stone-800 dark:text-stone-400 dark:hover:bg-stone-700"
>
{url} ↗
</a>
</div>
</div>
);
}