-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPostCard.astro
More file actions
61 lines (54 loc) · 1.37 KB
/
Copy pathPostCard.astro
File metadata and controls
61 lines (54 loc) · 1.37 KB
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
---
interface Props {
title: string;
date: Date;
slug: string;
description?: string;
tags?: string[];
compact?: boolean;
}
const { title, date, slug, description, tags = [], compact = false } = Astro.props;
const formattedDate = date.toLocaleDateString('en-US', {
year: 'numeric',
month: 'short',
day: 'numeric',
});
---
<article class="card group">
<a href={`/blog/${slug}/`} class="block p-5 h-full">
<time
datetime={date.toISOString()}
class="text-xs text-[var(--foreground-subtle)]"
>
{formattedDate}
</time>
<h3 class:list={[
'font-semibold text-[var(--foreground)] mt-2 group-hover:text-[var(--accent)] transition-colors line-clamp-2',
compact ? 'text-base' : 'text-lg',
]}>
{title}
</h3>
{!compact && description && (
<p class="text-sm text-[var(--foreground-muted)] mt-2 line-clamp-2">
{description}
</p>
)}
{!compact && tags.length > 0 && (
<div class="flex flex-wrap gap-2 mt-3">
{tags.slice(0, 3).map((tag) => (
<span class="text-xs text-[var(--foreground-subtle)] bg-[var(--background-tertiary)] px-2 py-0.5 rounded">
{tag}
</span>
))}
</div>
)}
</a>
</article>
<style>
.line-clamp-2 {
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
</style>