git ssb

7+

dinoworm ๐Ÿ› / patchcore



Tree: 8261134eb7daa7f16ad7f83ebb1549e60b37b70d

Files: 8261134eb7daa7f16ad7f83ebb1549e60b37b70d / plugs / message_render / post.js

884 bytesRaw
1var h = require('mutant/h')
2
3exports.needs = {
4 message_decorate: 'reduce',
5 message_layout: 'first',
6 message_link: 'first',
7 markdown: 'first'
8}
9
10exports.gives = {
11 message_render: true
12}
13
14exports.create = function (api) {
15 return {
16 message_render
17 }
18
19 function message_render (msg) {
20 if (msg.value.content.type !== 'post') return
21 var element = api.message_layout(msg, {
22 title: message_title(msg),
23 content: message_content(msg),
24 layout: 'default'
25 })
26
27 return api.message_decorate(element, { msg })
28 }
29
30 function message_content (data) {
31 if (!data.value.content || !data.value.content.text) return
32 return h('div', {}, api.markdown(data.value.content))
33 }
34
35 function message_title (data) {
36 var root = data.value.content && data.value.content.root
37 return !root ? null : h('span', ['re: ', api.message_link(root)])
38 }
39}
40

Built with git-ssb-web