aboutsummaryrefslogtreecommitdiff
path: root/src/mixins/comment.pug
blob: f6d7b5eb9d0f76d84f7a782305cd419e04426caf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
include ../utils

mixin infoContainer(data)
  div.comment-info-container
    | #{fmtnum(data.ups)} ↑
    |  · 
    span(class=`${data.is_submitter ? 'op' : ''}`)
      | u/#{data.author} #{data.is_submitter ? '(op)' : ''}
    |  · 
    if data.collapsed_reason_code == "DELETED"
      a(href=`https://undelete.pullpush.io${data.permalink}`) search on undelete
      |  · 
    | #{timeDifference(Date.now(), data.created * 1000)}

-
  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)
  - 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' : ''}`)
      details(id=`${data.id}` open="")
        summary.expand-comments
          +infoContainer(data)
        div.comment-body
          != data.body_html
        if hasReplyData
          div.replies
            each reply in data.replies.data.children
              +comment(reply, false, parent_id)