From 37951dcf56d46f6e7a0481c7d23e6aad1e8624fc Mon Sep 17 00:00:00 2001 From: Cassidy Williams <1454517+cassidoo@users.noreply.github.com> Date: Sun, 31 Dec 2023 00:26:04 -0600 Subject: [PATCH] Fix date formatting, add tags to blog header --- src/components/Tags.astro | 8 ++++---- src/layouts/BlogPost.astro | 29 +++++++++++++++++++++++++---- src/pages/index.astro | 5 ++++- src/pages/post/[slug].astro | 29 ++--------------------------- src/style/global.css | 2 +- 5 files changed, 36 insertions(+), 37 deletions(-) diff --git a/src/components/Tags.astro b/src/components/Tags.astro index f301a5d..b29462a 100644 --- a/src/components/Tags.astro +++ b/src/components/Tags.astro @@ -1,9 +1,9 @@ --- -const { tags } = Astro.props; +const { tags, all } = Astro.props; --- -

View posts by tag

-

+{all &&

View posts by tag

} +
{ tags && tags.map((tag) => ( @@ -15,4 +15,4 @@ const { tags } = Astro.props; )) } -

+
diff --git a/src/layouts/BlogPost.astro b/src/layouts/BlogPost.astro index f6e2eb7..6753227 100644 --- a/src/layouts/BlogPost.astro +++ b/src/layouts/BlogPost.astro @@ -7,11 +7,31 @@ import Tags from "../components/Tags.astro"; import getTags from "../scripts/getTags"; const posts = await Astro.glob("../posts/*.md"); -const tags = getTags(posts); +const allTags = getTags(posts); -const { - content: { title, description, added, updated, heroImage }, +let { + content: { title, description, added, updated, tags, heroImage }, } = Astro.props; + +added = new Date(added).toLocaleDateString( + "en-us", + { + year: "numeric", + month: "short", + day: "numeric", + } +); + +if (updated) { + updated = new Date(updated).toLocaleDateString( + "en-us", + { + year: "numeric", + month: "short", + day: "numeric", + } + ); +} --- @@ -28,13 +48,14 @@ const { : {added && } } +
- +