Files: c18b233c6d62741496978cd8dc1f34a093946f8b / message / html / link.js
533 bytesRaw
1 | var h = require('mutant/h') |
2 | var ref = require('ssb-ref') |
3 | |
4 | exports.needs = { |
5 | message_name: 'first' |
6 | } |
7 | |
8 | exports.gives = 'message_link' |
9 | |
10 | exports.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