Skip to content

Commit d56952d

Browse files
committed
change date sort
1 parent c499918 commit d56952d

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

src/data/posts.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ export async function getPublishedPosts() {
77
.filter((post) => !post.data.draft)
88
.sort(
99
(a, b) =>
10-
+(b.data.last_modified_at ?? b.data.published_at) -
11-
+(a.data.last_modified_at ?? a.data.published_at),
10+
+(b.published_at) -
11+
+(a.published_at),
1212
);
1313
}
1414

src/pages/index.astro

+2-10
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,12 @@ import PostListing from "../components/PostListing";
88
const publishedPosts = await getPublishedPosts();
99
1010
const recentPosts = publishedPosts
11-
.sort(
12-
(a, b) =>
13-
+(b.data.last_modified_at ?? b.data.published_at) -
14-
+(a.data.last_modified_at ?? a.data.published_at),
15-
)
11+
.sort((a, b) => +b.data.published_at - +a.data.published_at)
1612
.slice(0, config.layout.pageSize);
1713
1814
const featuredPosts = publishedPosts
1915
.filter((post) => post.data.featured)
20-
.sort(
21-
(a, b) =>
22-
+(b.data.last_modified_at ?? b.data.published_at) -
23-
+(a.data.last_modified_at ?? a.data.published_at),
24-
)
16+
.sort((a, b) => +b.data.published_at - +a.data.published_at)
2517
.slice(0, config.layout.pageSize);
2618
---
2719

0 commit comments

Comments
 (0)