git ssb

16+

Dominic / patchbay



Tree: 25a8b716544bd1f58eeba52a1feb6bb5a6eb78ae

Files: 25a8b716544bd1f58eeba52a1feb6bb5a6eb78ae / modules_basic / message-backlinks.js

889 bytesRaw
1var fs = require('fs')
2var Path = require('path')
3var h = require('../h')
4
5exports.gives = {
6 message_backlinks: true,
7 mcss: true
8}
9
10exports.create = function (api) {
11 return {
12 message_backlinks,
13 mcss: () => fs.readFileSync(Path.join(__dirname, 'message-backlinks.mcss'))
14 }
15
16 function message_backlinks (msg) {
17 var links = []
18 for(var k in CACHE) {
19 var _msg = CACHE[k]
20 if(Array.isArray(_msg.content.mentions)) {
21 for(var i = 0; i < _msg.content.mentions.length; i++)
22 if(_msg.content.mentions[i].link == msg.key)
23 links.push(k)
24 }
25 }
26
27 if (links.length === 0) return null
28
29 return h('MessageBacklinks', [
30 h('header', 'backlinks:'),
31 h('ul', links.map(function (link) {
32 return h('li', [
33 h('a -backlink', {
34 href: `#${link}`
35 }, link)
36 ])
37 }))
38 ])
39 }
40}
41

Built with git-ssb-web