Skip to content

Commit

Permalink
Sort post previews by date
Browse files Browse the repository at this point in the history
This component is used in the main page view but was not sorting the posts by their `date` attribute.
  • Loading branch information
njacobs5074 authored Feb 5, 2022
1 parent 4383d21 commit e052bf3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/components/PostPreviewList.astro
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
---
import PostPreview from './PostPreview.astro'
const { posts } = Astro.props
const sortedPosts = posts.sort((a, b) => new Date(b.date) - new Date(a.date));
---
<section class="post-preview__list">
{posts.map((post) => (
{sortedPosts.map((post) => (
<PostPreview post={post}/>
))}
</section>
Expand Down

0 comments on commit e052bf3

Please sign in to comment.