feat: add post card component with scroll animation

This commit is contained in:
2026-06-01 19:56:35 -05:00
parent 67a7b899f7
commit 40285d9ee6

View File

@@ -0,0 +1,29 @@
import Link from "next/link";
import { motion } from "motion/react";
import type { PostMeta } from "@/lib/posts";
interface PostCardProps extends PostMeta {
index?: number;
}
export function PostCard({ slug, title, date, excerpt, index = 0 }: PostCardProps) {
return (
<motion.article
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
transition={{ duration: 0.5, delay: index * 0.07 }}
viewport={{ once: true }}
className="scroll-mt-20"
>
<Link href={`/posts/${slug}/`} className="block">
<time className="font-mono text-sm text-ink-soft">{date}</time>
<h3 className="font-sans text-2xl font-semibold tracking-tight text-ink mt-1 mb-2 hover:text-accent transition-colors">
{title}
</h3>
{excerpt && (
<p className="text-ink-soft leading-7">{excerpt}</p>
)}
</Link>
</motion.article>
);
}