add recursive counter for links in replies

This commit is contained in:
plebeius.eth
2023-07-10 11:15:35 +02:00
parent b5ed8c0607
commit 873509e34d
4 changed files with 54 additions and 13 deletions
+20
View File
@@ -0,0 +1,20 @@
function countLinks(comment) {
let linkCount = 0;
if (comment.replyCount > 0) {
for (let reply of comment.replies.pages.topAll.comments) {
if (reply.link) {
linkCount++;
}
if (reply.replyCount > 0) {
linkCount += countLinks(reply);
}
}
}
return linkCount;
}
export default countLinks;