git ssb

16+

Dominic / patchbay



Tree: d6467d3650ae378a0c0509253c2ab80b74c89e7b

Files: d6467d3650ae378a0c0509253c2ab80b74c89e7b / modules / post.js

954 bytesRaw
1var markdown = require('ssb-markdown')
2var h = require('hyperscript')
3var u = require('../util')
4var ref = require('ssb-ref')
5
6//render a message
7
8exports.message_content = function (data, sbot) {
9 if(!data.value.content || !data.value.content.text) return
10
11 var root = data.value.content.root
12 var re = !root ? null : h('span', 're:',
13 u.decorate(exports.message_link, root, function (d, e, v) { return d(e, v, sbot) })
14 )
15
16 var content = h('div')
17 var d = h('div', re, content)
18
19 var mentions = {}
20 if(Array.isArray(data.value.content.mentions))
21 data.value.content.mentions.forEach(function (link) {
22 if(link.name) mentions["@"+link.name] = link.link
23 })
24
25 content.innerHTML =
26 markdown.block(data.value.content.text, {toUrl: function (id) {
27 if(ref.isBlob(id))
28 return 'http://localhost:7777/'+encodeURIComponent(id)
29 return '#'+(mentions[id]?mentions[id]:id)
30 }})
31 return d
32}
33
34exports.message_link = []
35
36
37
38
39
40

Built with git-ssb-web