diff options
| author | Kyren223 <Kyren223@proton.me> | 2024-11-13 20:24:37 +0200 |
|---|---|---|
| committer | Kyren223 <Kyren223@proton.me> | 2024-11-13 20:24:37 +0200 |
| commit | cda18a01652761645fe0169838e257f0581ca5b8 (patch) | |
| tree | 229a628f1ed2830bb276961b7091f83cc33e206a /src/pages/blogs.astro | |
| parent | 0267c91891773733f3320e344373e58a4c241579 (diff) | |
Added latest blog to home page
Diffstat (limited to 'src/pages/blogs.astro')
| -rw-r--r-- | src/pages/blogs.astro | 19 |
1 files changed, 1 insertions, 18 deletions
diff --git a/src/pages/blogs.astro b/src/pages/blogs.astro index c571090..128210c 100644 --- a/src/pages/blogs.astro +++ b/src/pages/blogs.astro @@ -4,29 +4,12 @@ import TerminalBorder from "../components/TerminalBorder.astro"; import BlogItem from "../components/BlogItem.astro"; import { getCollection } from "astro:content"; -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}`; -} - const blogs = (await getCollection("blogs")) .sort((a, b) => +new Date(b.data.date) - +new Date(a.data.date)) .map((blog) => ({ title: blog.data.title, description: blog.data.description, - date: formatDate(blog.data.date), + date: blog.data.date, href: "/blogs/" + blog.slug, })); --- |
