aboutsummaryrefslogtreecommitdiff
path: root/src/views/comments.pug
blob: 8d5acf37fb0291e9451940b4e916250d44789c1a (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
include ../mixins/comment
include ../mixins/header

doctype html
html
  head
    meta(charset='UTF-8')
    meta(name="viewport" content="width=device-width, initial-scale=1.0")
    title reddit
    link(rel='stylesheet', href='/styles.css')
    script(src="https://cdn.dashjs.org/latest/dash.all.min.js")
  body
    main#content
      +header()
      div.hero
        h3
          a(href=`/r/${post.subreddit}`) r/#{post.subreddit}

        h2 #{post.title}

        if post.is_gallery && post.is_gallery == true
          if post.gallery_data
            if post.gallery_data.items
              div.gallery
                - var total = post.gallery_data.items.length
                - var idx = 0
                each item in post.gallery_data.items
                  - var url = `https://i.redd.it/${item.media_id}.jpg`
                  div.gallery-item
                    a(href=`/media/${url}`)
                      img(src=url loading="lazy")
                    div.gallery-item-idx
                      | #{`${++idx}/${total}`}
        else if post.post_hint == "image" && post.thumbnail && post.thumbnail != "self" && post.thumbnail != "default"
          img(src=post.url).post-media
        else if post.post_hint == 'hosted:video'
          - var url = post.secure_media.reddit_video.dash_url
          video(controls data-dashjs-player src=`${url}`).post-media
        else if !post.selftext
          a(href=post.url)
            | #{post.url}

        if post.selftext_html
          p.self-text !{post.selftext_html}

        div.info-container 
          p
            | #{fmtnum(post.ups)} ↑ 
            |  ·  by u/#{post.author} 
            |  ·  
            | #{timeDifference(Date.now(), post.created * 1000)}

        hr

      div.comments-container
        each child in comments
          +comment(child, true)

    script(src='https://unpkg.com/[email protected]')