Skip to content

Commit

Permalink
Change date management
Browse files Browse the repository at this point in the history
  • Loading branch information
simonerlic committed Sep 3, 2024
1 parent 640e0db commit 19d6dc2
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 29 deletions.
60 changes: 33 additions & 27 deletions src/components/blog/TopEntries.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,41 @@ import "../../styles/blog-home.css";
const allPosts = await getCollection("posts");
const sortedPosts = allPosts.sort(
(a, b) => Number(new Date(b.data.pubDate)) - Number(new Date(a.data.pubDate))
(a, b) =>
Number(new Date(b.data.pubDate)) - Number(new Date(a.data.pubDate)),
);
---

<body class="relative min-h-screen">
<div class="recent-box">
<h3 class="mb-4">$ ls -a blog_entries/*.md</h3>
<ul class="space-y-4 sm:space-y-2">
{
sortedPosts.map((post) => (
<li>
<span class="pr-2">-rw-r--r-- 1 serlic serlic{" "}</span>
<span>
{new Date(post.data.pubDate).toLocaleDateString("en-US", {
month: "short",
day: "numeric",
})}
</span>
<a
href={`/posts/${post.slug}/`}
target="_blank"
rel="noopener noreferrer"
class="underline pl-2"
>
{post.data.filetitle}.md
</a>
</li>
))
}
</ul>
</div>
<div class="recent-box">
<h3 class="mb-4">$ ls -a blog_entries/*.md</h3>
<ul class="space-y-4 sm:space-y-2">
{
sortedPosts.map((post) => (
<li>
<span class="pr-2">
-rw-r--r-- 1 serlic serlic{" "}
</span>
<span>
{new Date(post.data.pubDate).toLocaleDateString(
"en-US",
{
month: "short",
day: "2-digit",
},
)}
</span>
<a
href={`/posts/${post.slug}/`}
target="_blank"
rel="noopener noreferrer"
class="underline pl-2"
>
{post.data.filetitle}.md
</a>
</li>
))
}
</ul>
</div>
</body>
3 changes: 1 addition & 2 deletions src/layouts/MarkdownPostLayout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ const { frontmatter, readTime } = Astro.props;
weekday: "long",
month: "long",
day: "numeric",
timeZone: "America/Vancouver",
},
)
}</span
>
<span class="mx-1"> • </span>
<span class="mx-2"> • </span>
<span>{readTime}</span>
</p>
<p></p>
Expand Down

0 comments on commit 19d6dc2

Please sign in to comment.