git ssb

7+

dinoworm ๐Ÿ› / patchcore



Tree: d5f37c13cd95a2e321a1e51db1e64eef746ee0ea

Files: d5f37c13cd95a2e321a1e51db1e64eef746ee0ea / message / html / backlinks.js

936 bytesRaw
1const h = require('mutant/h')
2const map = require('mutant/map')
3const computed = require('mutant/computed')
4const when = require('mutant/when')
5const nest = require('depnest')
6
7exports.needs = nest({
8 'message.obs.backlinks': 'first',
9 'message.obs.name': 'first',
10 'message.async.name': 'first',
11 'sbot.sync.cache': 'first'
12})
13
14exports.gives = nest('message.html.backlinks')
15
16exports.create = function (api) {
17 return nest('message.html.backlinks', function (msg) {
18 var backlinks = api.message.obs.backlinks(msg.key)
19 return when(computed(backlinks, hasItems),
20 h('MessageBacklinks', [
21 h('header', 'backlinks:'),
22 h('ul', [
23 map(backlinks, (link) => {
24 return h('li', [
25 h('a -backlink', { href: link, title: link }, api.message.obs.name(link))
26 ])
27 })
28 ])
29 ])
30 )
31 })
32}
33
34function hasItems (items) {
35 return (items && items.length)
36}
37

Built with git-ssb-web