From cda18a01652761645fe0169838e257f0581ca5b8 Mon Sep 17 00:00:00 2001 From: Kyren223 Date: Wed, 13 Nov 2024 20:24:37 +0200 Subject: Added latest blog to home page --- src/components/BlogItem.astro | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'src/components/BlogItem.astro') 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; --- - +

-- cgit v1.3.1