git ssb

0+

ev / microbay



forked from Dominic / patchbay

Tree: 2a990899321f909f52dce13715ee580d1e8507b6

Files: 2a990899321f909f52dce13715ee580d1e8507b6 / modules / post.js

952 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
8var plugs = require('../plugs')
9var message_link = plugs.first(exports.message_link = [])
10
11exports.message_content = function (data, sbot) {
12 if(!data.value.content || !data.value.content.text) return
13
14 var root = data.value.content.root
15 var re = !root ? null : h('span', 're: ', message_link(root))
16
17 var content = h('div')
18 var d = h('div', re, content)
19
20 var mentions = {}
21 if(Array.isArray(data.value.content.mentions))
22 data.value.content.mentions.forEach(function (link) {
23 if(link.name) mentions["@"+link.name] = link.link
24 })
25
26 content.innerHTML =
27 markdown.block(data.value.content.text, {toUrl: function (id) {
28 if(ref.isBlob(id))
29 return 'http://localhost:7777/'+encodeURIComponent(id)
30 return '#'+(mentions[id]?mentions[id]:id)
31 }})
32 return d
33}
34
35
36
37
38
39
40
41
42
43
44

Built with git-ssb-web