summaryrefslogtreecommitdiff
path: root/src/components/BlogItem.astro
blob: 0f49f9c09093730b00bc60a002ff93670a492b81 (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
44
45
46
47
48
49
50
51
52
53
54
55
---
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>

<style>
    .section:hover() {
        position: relative;
        padding: 10.8rem;
        padding-top: 0.85rem;
        display: flex;
        border-style: solid;
        border-width: 1px;
        border-color: var(--alt);
    }
</style>