summaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
authorKyren223 <Kyren223@proton.me>2024-11-13 20:24:37 +0200
committerKyren223 <Kyren223@proton.me>2024-11-13 20:24:37 +0200
commitcda18a01652761645fe0169838e257f0581ca5b8 (patch)
tree229a628f1ed2830bb276961b7091f83cc33e206a /src/components
parent0267c91891773733f3320e344373e58a4c241579 (diff)
Added latest blog to home page
Diffstat (limited to 'src/components')
-rw-r--r--src/components/BlogItem.astro24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/components/BlogItem.astro b/src/components/BlogItem.astro
index 1535621..0f49f9c 100644
--- a/src/components/BlogItem.astro
+++ b/src/components/BlogItem.astro
@@ -1,17 +1,35 @@
---
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: string;
+ date: Date;
href: string;
+ header?: string;
}
-const { title, description, date, href } = Astro.props;
+const { title, description, date, href, header } = Astro.props;
---
-<TerminalBorder footer={date} margin="0 0 20px;">
+<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">