summaryrefslogtreecommitdiff
path: root/src/components/BlogItem.astro
blob: d94b6f56e77e7765e8e3dcae35f3abbbcf51233f (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
41
42
43
---
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();

    let suffix = "th";
    if (day === 1 || day === 21 || day === 31) {
        suffix = "st";
    } else if (day === 2 || day === 22) {
        suffix = "nd";
    } else if (day === 3 || day === 23) {
        suffix = "rd";
    }

    return `${month} ${day}${suffix} ${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)} margin="0 0 20px;">
    <span class="cursor-pointer group block w-full">
        <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>
    </span>
</TerminalBorder>