Skip to content

Commit

Permalink
Update post.ts to properly return the latest post
Browse files Browse the repository at this point in the history
The previous function returns all posts in ascending order of pubDate, which doesn't fit the purpose of getting the latest posts.
  • Loading branch information
Celqaz authored Oct 30, 2023
1 parent 4ff66a1 commit 091ce64
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const getCategories = async () => {
export const getPosts = async (max?: number) => {
return (await getCollection('blog'))
.filter((post) => !post.data.draft)
.sort((a, b) => a.data.pubDate.valueOf() - b.data.pubDate.valueOf())
.sort((a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf())
.slice(0, max)
}

Expand Down

0 comments on commit 091ce64

Please sign in to comment.