git ssb

2+

mixmix / ticktack



Tree: f279e0482bb337ac884bc177d679b808a5821f23

Files: f279e0482bb337ac884bc177d679b808a5821f23 / blogs / blog.js

1399 bytesRaw
1var pull = require('pull-stream')
2const h = require('mutant').h
3
4exports.gives = {
5 message: {
6 html: {
7 title: true,
8 summary: true,
9 thumbnail: true,
10 content: true
11 }
12 }
13}
14
15exports.needs = {
16 message: { html: { markdown: 'first' } },
17 sbot: { pull: { stream: 'first' } }
18}
19
20
21exports.create = function (api) {
22
23 return {
24 message: {
25 html: {
26 title: function (data) {
27 if('blog' == typeof data.value.content.type) return
28 return data.value.content.title
29 },
30 summary: function (data) {
31 if('blog' == typeof data.value.content.type) return
32 return data.value.content.summary
33 },
34 thumbnail: function (data) {
35 if('blog' == typeof data.value.content.type) return
36 return data.value.content.thumbnail
37 },
38 content: function (data) {
39 if('blog' == typeof data.value.content.type) return
40 var div = h('Markdown')
41 pull(
42 api.sbot.pull.stream(function (sbot) {
43 return sbot.blobs.get(data.value.content.blog)
44 }),
45 pull.collect(function (err, ary) {
46 if(err) return
47 var md = api.message.html.markdown({text:Buffer.concat(ary).toString()})
48 div.innerHTML = md.innerHTML
49 })
50 )
51 return div
52 }
53 }
54 }
55 }
56}
57
58

Built with git-ssb-web