Commit 33d49d724c13b515841075e0ae6d096034c78275
backlinks: jump through the api.message_name hoop
Henry committed on 1/11/2017, 12:22:50 AMParent: bf289fc707717f3828ed39f6cfcfcc0c51d41947
Files changed
modules_basic/message-backlinks.js | changed |
modules_basic/message-backlinks.js | ||
---|---|---|
@@ -1,7 +1,11 @@ | ||
1 | 1 … | const fs = require('fs') |
2 | 2 … | const h = require('../h') |
3 | 3 … | |
4 … | +exports.needs = { | |
5 … | + message_name: 'first' | |
6 … | +} | |
7 … | + | |
4 | 8 … | exports.gives = { |
5 | 9 … | message_backlinks: true, |
6 | 10 … | mcss: true |
7 | 11 … | } |
@@ -26,14 +30,19 @@ | ||
26 | 30 … | } |
27 | 31 … | |
28 | 32 … | if (links.length === 0) return null |
29 | 33 … | |
34 … | + var hrefList = h('ul') | |
35 … | + links.forEach(link => { | |
36 … | + api.message_name(link, (err, name) => { | |
37 … | + if (err) throw err | |
38 … | + hrefList.appendChild(h('li', | |
39 … | + h('a -backlink', { href: `#${link}` }, name) | |
40 … | + )) | |
41 … | + }) | |
42 … | + }) | |
30 | 43 … | return h('MessageBacklinks', [ |
31 | 44 … | h('header', 'backlinks:'), |
32 | - h('ul', links.map(link => { | |
33 | - return h('li', [ | |
34 | - h('a -backlink', { href: `#${link}` }, link) | |
35 | - ]) | |
36 | - })) | |
45 … | + hrefList | |
37 | 46 … | ]) |
38 | 47 … | } |
39 | 48 … | } |
Built with git-ssb-web