diff options
| author | Kyren223 <Kyren223@proton.me> | 2024-11-13 00:00:30 +0200 |
|---|---|---|
| committer | Kyren223 <Kyren223@proton.me> | 2024-11-13 00:00:30 +0200 |
| commit | 5f18abf234a80b45ed6d1fd935c2f60b2599b87f (patch) | |
| tree | bb341343cc7b6aec1b71d73e264412bf07029346 /src/pages | |
| parent | 6d3da9537200e4029d3c9e1b6140f601642f26da (diff) | |
Finished /blogs yay
Diffstat (limited to 'src/pages')
| -rw-r--r-- | src/pages/blogs/index.astro | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/src/pages/blogs/index.astro b/src/pages/blogs/index.astro index de5252a..e91e580 100644 --- a/src/pages/blogs/index.astro +++ b/src/pages/blogs/index.astro @@ -4,19 +4,29 @@ import TerminalBorder from "../../components/TerminalBorder.astro"; import BlogItem from "../../components/BlogItem.astro"; import { getCollection } from "astro:content"; -const blogEntries = await getCollection("blogs"); +function formatDate(date) { + const day = date.getDate(); + const month = date.toLocaleString("default", { month: "long" }); // Get full month name + const year = date.getFullYear(); -const blogs = [ - { - title: "The search for the perfect ed25519 key pair", - description: ` -This is the description about this thing which shoud be very -long and cause this to wrap so that I can see how about 3 lines -of paragraph will look int this so now I am gonna continue -yapping to make it even longer`.trimStart(), - date: "November 12th 2024", - }, -]; + 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")).map((blog) => ({ + title: blog.data.title, + description: blog.data.description, + date: formatDate(blog.data.date), + href: "/blogs/" + blog.slug, +})); --- <Layout dir="blogs/"> @@ -31,6 +41,7 @@ yapping to make it even longer`.trimStart(), title={blog.title} description={blog.description} date={blog.date} + href={blog.href} /> </> )) |
