summaryrefslogtreecommitdiff
path: root/src/components/BlogItem.astro
blob: c61f62b5661cfa5067421eb71a0b906855772e39 (plain)
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
---
import TerminalBorder from "@components/TerminalBorder.astro";

function formatDate(date: Date) {
    const day = date.getDate();
    const month = date.toLocaleString("default", { month: "long" });
    const year = date.getFullYear();
    return `${month} ${day}, ${year}`;
}

interface Props {
    title: string;
    description: string;
    date: Date;
    href?: string;
    header?: string;
}

const { title, description, date, href, header } = Astro.props;
---

<TerminalBorder header={header} footer={formatDate(date)} extra="mb-[5vw] sm:mb-[2vw]">
    <span class="cursor-pointer group block w-full">
        {
            href ? (
                <a href={href} style="all: unset;">
                    <h1 class="text-[130%] text-[var(--accent)] group-hover:underline">
                        {title}
                    </h1>
                    <p class="text-[var(--secondary)]">{description}</p>
                </a>
            ) : (
                <>
                    <h1 class="text-[130%] text-[var(--accent)]">{title}</h1>
                    <p class="text-[var(--secondary)]">{description}</p>
                </>
            )
        }
    </span>
</TerminalBorder>