git ssb

0+

wanderer🌟 / %yCkm4no/U8C2k0Z658j…



forked from mixmix / patch-inbox

Tree: 1467096ba00c483e19443074f64ea107da692c4e

Files: 1467096ba00c483e19443074f64ea107da692c4e / message / html / render / post.js

1043 bytesRaw
1var nest = require('depnest')
2var h = require('mutant/h')
3
4exports.needs = nest({
5 'message.html': {
6 decorate: 'reduce',
7 layout: 'first',
8 link: 'first',
9 markdown: 'first'
10 }
11})
12
13exports.gives = nest('message.html.render')
14
15exports.create = function (api) {
16 return nest('message.html.render', function renderMessage (msg, opts) {
17 if (msg.value.content.type !== 'post') return
18 if (!opts || opts.layout !== 'inbox') return
19
20 var element = api.message.html.layout(msg, Object.assign({}, {
21 title: messageTitle(msg),
22 // content: messageContent(msg), // not needed
23 }, opts))
24
25 // decorate locally
26 if (msg.replies && msg.replies.length) {
27 element.dataset.root = msg.key
28 element.dataset.id = msg.replies[msg.replies.length-1].key
29 } else {
30 element.dataset.id = msg.key
31 }
32
33 return element
34 })
35
36 function messageTitle (data) {
37 var root = data.value.content && data.value.content.root
38 return !root ? null : h('span', ['re: ', api.message.html.link(root)])
39 }
40}
41
42

Built with git-ssb-web