gabeefran.co-blog/src/components/PostCard.astro

38 lines
1.2 KiB
Text

---
import type { PostEntry } from '../lib/posts';
import { slugOf, formatDate } from '../lib/posts';
import { getLocalizedPath, type Lang } from '../lib/i18n';
interface Props {
post: PostEntry;
lang: Lang;
}
const { post, lang } = Astro.props;
const href = getLocalizedPath(`/posts/${slugOf(post)}`, lang);
const tagsHref = (tag: string) => getLocalizedPath(`/tags/${tag}`, lang);
---
<article class="group border-b border-border py-6 first:pt-0 last:border-b-0 font-mono">
<a href={href} class="block">
<time datetime={post.data.pubDate.toISOString()} class="text-xs font-medium uppercase tracking-wide text-text-muted">
{formatDate(post.data.pubDate, lang)}
</time>
<h3 class="mt-1.5 text-xl font-semibold text-text group-hover:text-primary group-hover:underline">
{post.data.title}
</h3>
<p class="mt-1.5 text-[15px] leading-relaxed text-text-muted">{post.data.description}</p>
</a>
{post.data.tags.length > 0 && (
<div class="mt-3 flex flex-wrap gap-2">
{post.data.tags.map((tag) => (
<a
href={tagsHref(tag)}
class="text-text-muted px-1 py-0.5 text-sm hover:text-accent underline"
>
#{tag}
</a>
))}
</div>
)}
</article>