-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPostCard.astro
More file actions
64 lines (60 loc) · 1.73 KB
/
PostCard.astro
File metadata and controls
64 lines (60 loc) · 1.73 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
62
63
64
---
import { Image } from 'astro:assets';
import type { ImageMetadata } from 'astro';
interface Props {
title: string;
subtitle?: string;
slug: string;
date: Date;
description?: string;
categories: string[];
image?: ImageMetadata;
}
const { title, subtitle, slug, date, description, categories, image } = Astro.props;
const formattedDate = date.toLocaleDateString('en-US', {
year: 'numeric',
month: 'long',
day: 'numeric',
timeZone: 'America/New_York'
});
---
<article class="bg-background-2 rounded-lg overflow-hidden hover:bg-background-3 transition-colors relative">
{image && (
<a href={`/${slug}/`} class="block aspect-video overflow-hidden">
<Image
src={image}
alt={title}
width={1920}
height={1080}
quality={80}
format="webp"
class="w-full h-full object-cover hover:scale-105 transition-transform duration-300"
loading="lazy"
/>
</a>
)}
<div class="p-6 min-h-[320px] pb-12">
<div class="flex flex-wrap gap-2 mb-3">
{categories.map(category => (
<a
href={`/category/${category.toLowerCase()}/`}
class="text-xs bg-primary/20 text-primary px-2 py-1 rounded no-underline hover:bg-primary/30"
>
{category}
</a>
))}
</div>
<h2 class="text-xl font-heading mb-1">
<a href={`/${slug}/`} class="text-text hover:text-primary no-underline">
{title}
</a>
</h2>
{subtitle && (
<p class="text-[#FFB833] text-sm mb-2">{subtitle}</p>
)}
{description && (
<p class="text-text-muted text-sm mb-3 line-clamp-6">{description}</p>
)}
<time class="text-text-muted text-xs absolute bottom-6 right-6">{formattedDate}</time>
</div>
</article>