Files: 1467096ba00c483e19443074f64ea107da692c4e / message / html / render / post.js
1043 bytesRaw
1 | var nest = require('depnest') |
2 | var h = require('mutant/h') |
3 | |
4 | exports.needs = nest({ |
5 | 'message.html': { |
6 | decorate: 'reduce', |
7 | layout: 'first', |
8 | link: 'first', |
9 | markdown: 'first' |
10 | } |
11 | }) |
12 | |
13 | exports.gives = nest('message.html.render') |
14 | |
15 | exports.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