git ssb

16+

Dominic / patchbay



Tree: 134d423c26820a78c6bbfbc506df577e0673b6b2

Files: 134d423c26820a78c6bbfbc506df577e0673b6b2 / modules / post.js

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

Built with git-ssb-web