feat: PostCard card boundary + author + reading time
- Card: rounded-xl, border, bg-canvas, p-6, hover shadow-card - Author and reading time on meta line with · separators - Tags use rounded-full pill shape (consistent with post detail) - Title hover via group-hover:text-accent - Excerpt uses leading-relaxed text-sm
This commit is contained in:
@@ -1,38 +1,40 @@
|
|||||||
"use client";
|
'use client';
|
||||||
|
|
||||||
import Link from "next/link";
|
import Link from 'next/link';
|
||||||
import { m } from "motion/react";
|
import { m } from 'motion/react';
|
||||||
import type { PostMeta } from "@/lib/posts";
|
import type { PostMeta } from '@/lib/posts';
|
||||||
|
|
||||||
interface PostCardProps extends PostMeta {
|
export function PostCard({ slug, title, date, excerpt, tags = [], author, readingTime, index = 0 }: PostMeta & { index?: number }) {
|
||||||
index?: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function PostCard({ slug, title, date, excerpt, index = 0, tags = [] }: PostCardProps) {
|
|
||||||
return (
|
return (
|
||||||
<m.article
|
<m.article
|
||||||
initial={{ opacity: 0, y: 20 }}
|
initial={{ opacity: 0, y: 20 }}
|
||||||
whileInView={{ opacity: 1, y: 0 }}
|
whileInView={{ opacity: 1, y: 0 }}
|
||||||
transition={{ duration: 0.5, delay: index * 0.07 }}
|
transition={{ duration: 0.5, delay: index * 0.07 }}
|
||||||
viewport={{ once: true }}
|
viewport={{ once: true }}
|
||||||
className="scroll-mt-20"
|
className="group relative scroll-mt-20 rounded-xl border border-border bg-canvas p-6 transition-all hover:border-border/80 hover:shadow-card"
|
||||||
>
|
>
|
||||||
<Link href={`/posts/${slug}/`} className="block">
|
<Link href={`/posts/${slug}/`} className="block">
|
||||||
<time className="font-mono text-sm text-ink-soft">{date}</time>
|
<div className="flex items-center gap-3 text-xs text-ink-soft mb-3">
|
||||||
<h3 className="heading-md text-ink mt-1 mb-2 hover:text-accent transition-colors">
|
<time className="font-mono">{date}</time>
|
||||||
|
{author && <span className="text-ink-soft/70">·</span>}
|
||||||
|
{author && <span>{author}</span>}
|
||||||
|
{readingTime && <span className="text-ink-soft/70">·</span>}
|
||||||
|
{readingTime && <span className="font-mono">{readingTime} min read</span>}
|
||||||
|
</div>
|
||||||
|
<h3 className="heading-md text-ink mt-0 mb-3 group-hover:text-accent transition-colors">
|
||||||
{title}
|
{title}
|
||||||
</h3>
|
</h3>
|
||||||
{tags && tags.length > 0 && (
|
{tags && tags.length > 0 && (
|
||||||
<div className="flex flex-wrap gap-1 mt-2">
|
<div className="flex flex-wrap gap-1.5 mt-3">
|
||||||
{tags.slice(0, 3).map((tag) => (
|
{tags.slice(0, 3).map((tag) => (
|
||||||
<span key={tag} className="rounded bg-surface px-2 py-0.5 text-xs text-ink-soft">
|
<span key={tag} className="rounded-full bg-surface/50 border border-border px-2.5 py-0.5 text-xs text-ink-soft">
|
||||||
{tag}
|
{tag}
|
||||||
</span>
|
</span>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{excerpt && (
|
{excerpt && (
|
||||||
<p className="text-ink-soft leading-7 mt-2">{excerpt}</p>
|
<p className="text-ink-soft leading-relaxed mt-3 text-sm">{excerpt}</p>
|
||||||
)}
|
)}
|
||||||
</Link>
|
</Link>
|
||||||
</m.article>
|
</m.article>
|
||||||
|
|||||||
Reference in New Issue
Block a user