portfolio/lib/comments.ts
Ryan Freeman 4abb9cb689
All checks were successful
Build And Publish / BuildAndPublish (push) Successful in 3m18s
Update comment component
2025-05-15 21:18:24 +01:00

9 lines
278 B
TypeScript

import type {Comment} from '@/types'
export function getCommentCount(comments: Comment[]) {
return comments.reduce((acc, comment) => {
if (!comment) return acc
const replyCount = comment.replies?.length || 0
return (acc + 1) + replyCount
}, 0)
}