Files: 6165433879b4b23dc7e1435ca5bf81275ebb508f / message / html / render / issue.js
982 bytesRaw
1 | var h = require('mutant/h') |
2 | var nest = require('depnest') |
3 | var extend = require('xtend') |
4 | |
5 | exports.needs = nest({ |
6 | 'message.html': { |
7 | decorate: 'reduce', |
8 | layout: 'first', |
9 | link: 'first', |
10 | markdown: 'first' |
11 | } |
12 | }) |
13 | |
14 | exports.gives = nest({ |
15 | 'message.html': { |
16 | canRender: true, |
17 | render: true |
18 | } |
19 | }) |
20 | |
21 | exports.create = function (api) { |
22 | return nest('message.html', { |
23 | canRender: isRenderable, |
24 | render: function (msg, opts) { |
25 | if (!isRenderable(msg)) return |
26 | var element = api.message.html.layout(msg, extend({ |
27 | content: messageContent(msg), |
28 | layout: 'default' |
29 | }, opts)) |
30 | |
31 | return api.message.html.decorate(element, { |
32 | msg |
33 | }) |
34 | } |
35 | }) |
36 | |
37 | function messageContent (data) { |
38 | if (!data.value.content || !data.value.content.text) return |
39 | return h('div', {}, api.message.html.markdown(data.value.content)) |
40 | } |
41 | |
42 | function isRenderable (msg) { |
43 | return msg.value.content.type === 'issue' ? true : undefined |
44 | } |
45 | } |
46 |
Built with git-ssb-web