Skip to content

Commit

Permalink
feat(sort-article): sort article based on date
Browse files Browse the repository at this point in the history
  • Loading branch information
jerensl committed Apr 25, 2024
1 parent 1ecf2e5 commit 50cd389
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/libs/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,13 @@ async function getContents<T>(directory: string): Promise<Array<T>> {
})
)

return contents.filter((data) => {
return data.isPublished === true
})
return contents
.filter((data) => {
return data.isPublished === true
})
.sort((a, b) => {
return Date.parse(b.date) - Date.parse(a.date)
})
}

export const getContent = async (
Expand Down

0 comments on commit 50cd389

Please sign in to comment.