summaryrefslogtreecommitdiffstats
path: root/src/utils/helpers/sort.ts
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2021-12-20 00:15:20 +0100
committerArmand Philippot <git@armandphilippot.com>2021-12-20 00:15:20 +0100
commitfa6adedc42e9c6ec39cc30df16b54900c220b094 (patch)
tree6bb498beadaa382245cecb86ce56931580313c6f /src/utils/helpers/sort.ts
parent2ff898626c5c0abc6b8195224067b992403e313b (diff)
refactor: rewrite types and services
I was repeating myself a lot in services. So I rewrited the different functions to improve readability and I extracted some formatting functions to put them in utils. I also rewrited/reorganized some types to keep consistent names.
Diffstat (limited to 'src/utils/helpers/sort.ts')
-rw-r--r--src/utils/helpers/sort.ts4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/utils/helpers/sort.ts b/src/utils/helpers/sort.ts
index ade82d0..c1ee35d 100644
--- a/src/utils/helpers/sort.ts
+++ b/src/utils/helpers/sort.ts
@@ -10,7 +10,9 @@ export const sortPostsByYear = (data: PostsList[]) => {
data.forEach((page) => {
page.posts.forEach((post) => {
- const postYear = new Date(post.date.publication).getFullYear().toString();
+ const postYear = new Date(post.dates.publication)
+ .getFullYear()
+ .toString();
yearCollection[postYear] = [...(yearCollection[postYear] || []), post];
});
});