aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlonkaars <l.leblansch@gmail.com>2021-04-12 10:52:04 +0200
committerlonkaars <l.leblansch@gmail.com>2021-04-12 10:52:04 +0200
commitf0e25c71e148758a76ee8d4807aa1262f25edc5d (patch)
tree071fb6fe2798aa6a91e25a016609d161ffb567bf
parentfe397455cb985f1f704dcb684af14df50c054294 (diff)
sort posts in posts.json
-rw-r--r--pages/search.tsx2
-rwxr-xr-xscripts/genposts6
2 files changed, 6 insertions, 2 deletions
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]);
diff --git a/scripts/genposts b/scripts/genposts
index b6aff64..0c6bfe0 100755
--- a/scripts/genposts
+++ b/scripts/genposts
@@ -1,2 +1,6 @@
#!/bin/sh
-./posts | jq -c > ../public/posts.json
+./posts |\
+ jq ".posts |= sort_by(.date)" |\
+ jq -c \
+ > ../public/posts.json
+