From fa6adedc42e9c6ec39cc30df16b54900c220b094 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Mon, 20 Dec 2021 00:15:20 +0100 Subject: 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. --- src/utils/helpers/sort.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/utils/helpers/sort.ts') 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]; }); }); -- cgit v1.2.3