Files: f1d5a7c472bb8e838a7fd395f59be8d473f8a872 / blogs / blog.js
1328 bytesRaw
1 | var pull = require('pull-stream') |
2 | const h = require('mutant').h |
3 | |
4 | exports.gives = { |
5 | message: { |
6 | html: { |
7 | title: true, |
8 | summary: true, |
9 | thumbnail: true, |
10 | content: true |
11 | } |
12 | } |
13 | } |
14 | |
15 | exports.needs = { |
16 | message: { html: { markdown: 'first' } }, |
17 | sbot: { pull: { getBlob: 'first' } } |
18 | } |
19 | |
20 | |
21 | exports.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.title |
33 | }, |
34 | thumbnail: function (data) { |
35 | if('blog' == typeof data.value.content.type) return |
36 | return data.value.content.title |
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.getBlob(data.value.content.blog), |
43 | pull.collect(function (err, ary) { |
44 | if(err) return |
45 | var md = api.message.html.markdown({text:Buffer.concat(ary).toString()}) |
46 | div.innerHTML = md.innerHTML |
47 | }) |
48 | ) |
49 | return div |
50 | } |
51 | } |
52 | } |
53 | } |
54 | } |
55 | |
56 | |
57 | |
58 |
Built with git-ssb-web