From 72f289fc37e2d5d5a5b7193929361f49fbd8f69a Mon Sep 17 00:00:00 2001 From: Rui Sousa Date: Fri, 25 Oct 2024 11:49:01 +0100 Subject: [PATCH] fix: total article calculation logic issue Simplifies and fixes total article calculation logic to loop through the different content types and increment its lengts. Closes #33 --- src/app/_utilities/calculateTotalArticles.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/app/_utilities/calculateTotalArticles.ts b/src/app/_utilities/calculateTotalArticles.ts index e5c1e72..07a0133 100644 --- a/src/app/_utilities/calculateTotalArticles.ts +++ b/src/app/_utilities/calculateTotalArticles.ts @@ -11,7 +11,11 @@ export function calculateTotalArticles(content: { CaseStudies: CaseStudy[] TalksAndRoundtables: TalksAndRoundtable[] }): number { - return Object.values(content).filter( - innerArray => Array.isArray(innerArray) && innerArray.length > 0, - ).length + let contentCount = 0 + for (const type in content) { + if (content[type].length > 0) { + contentCount += content[type].length + } + } + return contentCount }