From f0e25c71e148758a76ee8d4807aa1262f25edc5d Mon Sep 17 00:00:00 2001 From: lonkaars Date: Mon, 12 Apr 2021 10:52:04 +0200 Subject: sort posts in posts.json --- pages/search.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pages') diff --git a/pages/search.tsx b/pages/search.tsx index 8eff8d8..db5cc89 100644 --- a/pages/search.tsx +++ b/pages/search.tsx @@ -111,7 +111,6 @@ export default function SearchPage() { var posts = await fetch('/posts.json'); var postsJson: PostsInfo = await posts.json(); - postsJson.posts = postsJson.posts.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime()); setPosts(postsJson); setQuery(query); })(); @@ -135,6 +134,7 @@ export default function SearchPage() { } return true; }); + results = results.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime()); setVisiblePosts(results); }, [query]); -- cgit v1.2.3