include ../utils mixin infoContainer(data, next_id, prev_id) - var hats = (data.is_submitter?['op']:[]).concat(data.distinguished=="moderator"?['mod']:[]) div.comment-info-container p | #{fmtnum(data.ups)} ↑ | ·  if next_id a(href=`#${next_id}` title="scroll to next comment").nav-link next |  ·  if prev_id a(href=`#${prev_id}` title="scroll to previous comment").nav-link prev |  ·  if data.gilded > 0 span.gilded | #{data.gilded} ☆ |  ·  span(class=`${data.is_submitter ? 'op' : ''}`) | u/#{data.author} #{hats.length==0?'':`(${hats.join('|')})`} |  ·  if data.collapsed_reason_code == "DELETED" || data.author == "[deleted]" a(href=`https://undelete.pullpush.io${data.permalink}`) search on undelete |  ·  | #{timeDifference(Date.now(), data.created * 1000)} |  ·  if data.edited !== false | edited #{timeDifference(Date.now(), data.edited * 1000)} ago |  ·  if data.stickied | stickied |  ·  a(href=`https://reddit.com${data.permalink}` title="view on reddit").nav-link open ↗ - function hasReplies(data) { return data.replies && data.replies.data && data.replies.data.children && data.replies.data.children.length > 0; } mixin comment(com, isfirst, parent_id, next_id, prev_id) - var data = com.data - var hasReplyData = hasReplies(data) if com.kind == "more" div(class=`more ${isfirst ? 'first' : ''}`) a(href=`/comments/${parent_id}/comment/${data.id}`) | #{data.count} more #{fmttxt(data.count, 'comment')} else div(class=`comment ${isfirst ? 'first' : ''} ${data.stickied ? 'sticky' : ''}`) details(id=`${data.id}` open="") summary.expand-comments +infoContainer(data, next_id, prev_id) div.comment-body != data.body_html if hasReplyData div.replies - var total = data.replies.data.children.length each reply, index in data.replies.data.children - var next_idx = index + 1 - var prev_idx = index - 1 - var next_com = next_idx < total ? data.replies.data.children[next_idx] : null - var prev_com = prev_idx >= 0 ? data.replies.data.children[prev_idx] : null - var next_id = next_com ? next_com.data.id : null - var prev_id = prev_com ? prev_com.data.id : null +comment(reply, false, parent_id, next_id, prev_id)