Skip to content

Commit 78e4695

Browse files
Sort By Updated Date
1 parent 352c0df commit 78e4695

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/pages/index.astro

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ const allPosts = allMarkdownPosts
3636
: undefined,
3737
url: post.url,
3838
}))
39-
.sort((a, b) => b.date.valueOf() - a.date.valueOf())
39+
.sort((a, b) => {
40+
let aDate = a.updatedDate?.valueOf() ?? a.date.valueOf()
41+
let bDate = b.updatedDate?.valueOf() ?? b.date.valueOf()
42+
return bDate - aDate
43+
})
4044
4145
// Full Astro Component Syntax:
4246
// https://docs.astro.build/core-concepts/astro-components/

0 commit comments

Comments
 (0)