Skip to content

Commit

Permalink
Merge pull request #51 from WebDevSimplified/fix-sorting
Browse files Browse the repository at this point in the history
Sort By Updated Date
  • Loading branch information
WebDevSimplified authored Dec 2, 2024
2 parents 89b410c + 78e4695 commit b382340
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ const allPosts = allMarkdownPosts
: undefined,
url: post.url,
}))
.sort((a, b) => b.date.valueOf() - a.date.valueOf())
.sort((a, b) => {
let aDate = a.updatedDate?.valueOf() ?? a.date.valueOf()
let bDate = b.updatedDate?.valueOf() ?? b.date.valueOf()
return bDate - aDate
})
// Full Astro Component Syntax:
// https://docs.astro.build/core-concepts/astro-components/
Expand Down

0 comments on commit b382340

Please sign in to comment.