Skip to content

Commit

Permalink
add date to homepage (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
vernak2539 committed Apr 24, 2024
1 parent 5d76b23 commit 81505f4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { getCollection } from "astro:content";
import Card from "../components/Scaffolding/Card.astro";
import BaseLayout from "../layouts/BaseLayout.astro";
import { sortByPubdateMostRecentFirst } from "../utils/sort-posts";
import { formatDate } from "../utils/datetime-fmt";
const latestPost = (await getCollection("blog"))
.filter((post) => !post.data.redirect)
Expand All @@ -17,8 +18,8 @@ const blogPath = "/blog";
<p>
But really, I'm making this site for my explorations into FE tech
things. <a href={`${blogPath}/a-new-blog-why`}>This blog post</a>
explains a bit more about why I'm doing this. Should be fun. In the
meantime, checkout some silly things below that I do elsewhere.
explains a bit more about why I'm doing this. Should be fun. In the meantime,
checkout some silly things below that I do elsewhere.
</p>

<p class="smaller">
Expand All @@ -34,7 +35,7 @@ const blogPath = "/blog";
title={latestPost.data.title}
body={latestPost.data.description}
href={`${blogPath}/${latestPost.slug}`}
label="Latest"
label={`Latest (${formatDate(latestPost.data.pubDate)})`}
/>
<Card
title="All Posts"
Expand Down
2 changes: 1 addition & 1 deletion src/utils/datetime-fmt.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const formatDate = (input: Date): string => {
return input.toLocaleDateString("en-us", {
return input.toLocaleDateString(undefined, {
year: "numeric",
month: "short",
day: "numeric",
Expand Down

0 comments on commit 81505f4

Please sign in to comment.