selfhostable, read-only reddit client
16
fork

Configure Feed

Select the types of activity you want to include in your feed.

add next/prev links to comments

Akshay 2dcddd94 0d4d90ba

+47 -12
+19 -6
src/mixins/comment.pug
··· 1 1 include ../utils 2 2 3 - mixin infoContainer(data) 3 + mixin infoContainer(data, next_id, prev_id) 4 4 div.comment-info-container 5 5 | #{fmtnum(data.ups)} ↑ 6 - | &nbsp;·&nbsp; 6 + | ·&nbsp; 7 + if next_id 8 + a(href=`#${next_id}`).nav-link next 9 + | &nbsp;·&nbsp; 10 + if prev_id 11 + a(href=`#${prev_id}`).nav-link prev 12 + | &nbsp;·&nbsp; 7 13 span(class=`${data.is_submitter ? 'op' : ''}`) 8 14 | u/#{data.author} #{data.is_submitter ? '(op)' : ''} 9 15 | &nbsp;·&nbsp; ··· 17 23 return data.replies && data.replies.data && data.replies.data.children && data.replies.data.children.length > 0; 18 24 } 19 25 20 - mixin comment(com, isfirst, parent_id) 26 + mixin comment(com, isfirst, parent_id, next_id, prev_id) 21 27 - var data = com.data 22 28 - var hasReplyData = hasReplies(data) 23 29 ··· 29 35 div(class=`comment ${isfirst ? 'first' : ''}`) 30 36 details(id=`${data.id}` open="") 31 37 summary.expand-comments 32 - +infoContainer(data) 38 + +infoContainer(data, next_id, prev_id) 33 39 div.comment-body 34 40 != data.body_html 35 41 if hasReplyData 36 42 div.replies 37 - each reply in data.replies.data.children 38 - +comment(reply, false, parent_id) 43 + - var total = data.replies.data.children.length 44 + each reply, index in data.replies.data.children 45 + - var next_idx = index + 1 46 + - var prev_idx = index - 1 47 + - var next_com = next_idx < total ? data.replies.data.children[next_idx] : null 48 + - var prev_com = prev_idx >= 0 ? data.replies.data.children[prev_idx] : null 49 + - var next_id = next_com ? next_com.data.id : null 50 + - var prev_id = prev_com ? prev_com.data.id : null 51 + +comment(reply, false, parent_id, next_id, prev_id)
+1 -1
src/mixins/post.pug
··· 13 13 | #{fmtnum(p.ups)} ↑ 14 14 span.post-author 15 15 | &nbsp;·&nbsp; 16 - by u/#{p.author} 16 + | u/#{p.author} 17 17 | &nbsp;·&nbsp; 18 18 | #{timeDifference(Date.now(), p.created * 1000)} 19 19 | &nbsp;·&nbsp;
+10 -1
src/public/styles.css
··· 33 33 :root { font-family: InterVariable, sans-serif; } 34 34 } 35 35 36 + html { 37 + scroll-behavior: smooth; 38 + } 39 + 36 40 body { 37 41 overflow-x: hidden; 38 42 background-color: var(--bg-color); ··· 50 54 .info-container a, 51 55 .comment-info-container a, 52 56 .sort-opts a, 53 - .more a { 57 + .more a 58 + { 54 59 text-decoration: none; 55 60 } 56 61 ··· 565 570 .about { 566 571 padding-bottom: 20px; 567 572 } 573 + 574 + a.nav-link { 575 + color: var(--text-color-muted); 576 + }
+9 -2
src/views/comments.pug
··· 59 59 hr 60 60 61 61 div.comments-container 62 - each child in comments 63 - +comment(child, true, post.id) 62 + - var total = comments.length 63 + each child, index in comments 64 + - var next_idx = index + 1 65 + - var prev_idx = index - 1 66 + - var next_com = next_idx < total ? comments[next_idx] : null 67 + - var prev_com = prev_idx >= 0 ? comments[prev_idx] : null 68 + - var next_id = next_com ? next_com.data.id : null 69 + - var prev_id = prev_com ? prev_com.data.id : null 70 + +comment(child, true, post.id, next_id, prev_id)
+8 -2
src/views/single_comment_thread.pug
··· 16 16 div 17 17 p nothing to see here, this thread was shadow-banned? 18 18 else 19 - each comment in comments 20 - +comment(comment, true, parent_id) 19 + each comment, index in comments 20 + - var next_idx = index + 1 21 + - var prev_idx = index - 1 22 + - var next_com = next_idx < total ? comments[next_idx] : null 23 + - var prev_com = prev_idx >= 0 ? comments[prev_idx] : null 24 + - var next_id = next_com ? next_com.data.id : null 25 + - var prev_id = prev_com ? prev_com.data.id : null 26 + +comment(comment, true, parent_id, next_idx, prev_idx) 21 27