Skip to content

Commit

Permalink
fix: total article calculation logic issue
Browse files Browse the repository at this point in the history
Simplifies and fixes total article calculation logic to loop through the
different content types and increment its lengts.

Closes #33
  • Loading branch information
rccsousa committed Oct 25, 2024
1 parent d3bf946 commit 72f289f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/app/_utilities/calculateTotalArticles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 72f289f

Please sign in to comment.