git ssb

7+

dinoworm ๐Ÿ› / patchcore



Tree: c18b233c6d62741496978cd8dc1f34a093946f8b

Files: c18b233c6d62741496978cd8dc1f34a093946f8b / message / html / link.js

533 bytesRaw
1var h = require('mutant/h')
2var ref = require('ssb-ref')
3
4exports.needs = {
5 message_name: 'first'
6}
7
8exports.gives = 'message_link'
9
10exports.create = function (api) {
11 return function (id) {
12 if (typeof id !== 'string') { throw new Error('link must be to message id') }
13
14 var link = h('a', {href: '#' + id}, id.substring(0, 10) + '...')
15
16 if (ref.isMsg(id)) {
17 api.message_name(id, function (err, name) {
18 if (err) console.error(err)
19 else link.textContent = name
20 })
21 }
22
23 return link
24 }
25}
26

Built with git-ssb-web