git ssb

7+

dinoworm ๐Ÿ› / patchcore



Tree: 12f9e4861605413f2f160d9b2f15e4810a1c17b0

Files: 12f9e4861605413f2f160d9b2f15e4810a1c17b0 / message / html / render / post.js

1049 bytesRaw
1var h = require('mutant/h')
2var nest = require('depnest')
3var extend = require('xtend')
4
5exports.needs = nest({
6 'message.html': {
7 decorate: 'reduce',
8 layout: 'first',
9 link: 'first',
10 markdown: 'first'
11 }
12})
13
14exports.gives = nest('message.html.render')
15
16exports.create = function (api) {
17 return nest('message.html.render', function renderMessage (msg, opts) {
18 if (msg.value.content.type !== 'post') return
19 var element = api.message.html.layout(msg, extend({
20 title: messageTitle(msg),
21 content: msg.isBlocked ? 'Content of a blocked user' : messageContent(msg),
22 layout: 'default'
23 }, opts))
24
25 return api.message.html.decorate(element, { msg })
26 })
27
28 function messageContent (data) {
29 if (!data.value.content || !data.value.content.text) return
30 return h('div', {}, api.message.html.markdown(data.value.content))
31 }
32
33 function messageTitle (data) {
34 var root = data.value.content && data.value.content.root
35 return !root ? null : h('span', ['re: ', api.message.html.link(root)])
36 }
37}
38

Built with git-ssb-web