Skip to content

Commit

Permalink
fix: Tag pages not sorting by date
Browse files Browse the repository at this point in the history
  • Loading branch information
rjkilpatrick committed Jan 8, 2023
1 parent b1e7a21 commit 23c7970
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/pages/tags/[tag].astro
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ const { tag } = Astro.params;
<PageLayout title={tag}>
<h1>#{tag}</h1>
<section>
{posts.map((post) => <PostPreview post={post} />)}
{
posts
// Reverse chronological order
.sort(
(a, b) =>
new Date(b.frontmatter.datePublished).getTime() -
new Date(a.frontmatter.datePublished).getTime()
)
.map((post) => <PostPreview post={post} />)
}
</section>
</PageLayout>

0 comments on commit 23c7970

Please sign in to comment.