function conversationLength(note) { return note.replies.reduce((total, reply) => { return total + conversationLength(reply); }, 1); } module.exports = function (eleventyConfig) { // Filter out notes so that it's only notes that aren't replying to a post eleventyConfig.addFilter('topLevelNotes', function (notes) { return notes.filter(note => !note.replyId); }); eleventyConfig.addFilter('conversationLength', conversationLength); }