Files: d5f37c13cd95a2e321a1e51db1e64eef746ee0ea / message / html / backlinks.js
936 bytesRaw
1 | const h = require('mutant/h') |
2 | const map = require('mutant/map') |
3 | const computed = require('mutant/computed') |
4 | const when = require('mutant/when') |
5 | const nest = require('depnest') |
6 | |
7 | exports.needs = nest({ |
8 | 'message.obs.backlinks': 'first', |
9 | 'message.obs.name': 'first', |
10 | 'message.async.name': 'first', |
11 | 'sbot.sync.cache': 'first' |
12 | }) |
13 | |
14 | exports.gives = nest('message.html.backlinks') |
15 | |
16 | exports.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 | |
34 | function hasItems (items) { |
35 | return (items && items.length) |
36 | } |
37 |
Built with git-ssb-web