Files: 9fff2bb9c8cf22a5430644eaf74038867de5071d / app / page / blogShow.js
1771 bytesRaw
1 | const nest = require('depnest') |
2 | const { h, computed, when } = require('mutant') |
3 | const { title: getTitle } = require('markdown-summary') |
4 | const last = require('lodash/last') |
5 | const get = require('lodash/get') |
6 | |
7 | exports.gives = nest('app.page.blogShow') |
8 | |
9 | exports.needs = nest({ |
10 | 'about.html.avatar': 'first', |
11 | 'about.obs.name': 'first', |
12 | 'app.html.comments': 'first', |
13 | 'app.html.context': 'first', |
14 | 'contact.html.follow': 'first', |
15 | 'message.html.channel': 'first', |
16 | 'message.html.markdown': 'first', |
17 | 'message.html.timeago': 'first', |
18 | 'feed.obs.thread': 'first' |
19 | }) |
20 | |
21 | exports.create = (api) => { |
22 | return nest('app.page.blogShow', blogShow) |
23 | |
24 | function blogShow (blogMsg) { |
25 | // blogMsg = a thread (message, may be decorated with replies) |
26 | |
27 | const { author, content } = blogMsg.value |
28 | |
29 | const blog = content.text |
30 | const title = api.message.html.markdown(content.title || getTitle(blog)) |
31 | |
32 | const comments = api.app.html.comments(blogMsg.key) |
33 | |
34 | const { lastId: branch } = api.feed.obs.thread(blogMsg.key) |
35 | |
36 | const { timeago, channel, markdown, compose } = api.message.html |
37 | |
38 | return h('Page -blogShow', [ |
39 | api.app.html.context({ page: 'discover' }), // HACK to highlight discover |
40 | h('div.content', [ |
41 | h('header', [ |
42 | h('div.blog', [ |
43 | h('h1', title), |
44 | timeago(blogMsg), |
45 | channel(blogMsg) |
46 | ]), |
47 | h('div.author', [ |
48 | h('div.leftCol', api.about.html.avatar(author, 'medium')), |
49 | h('div.rightCol', [ |
50 | h('div.name', api.about.obs.name(author)), |
51 | api.contact.html.follow(author) |
52 | ]), |
53 | ]) |
54 | ]), |
55 | h('div.break', h('hr')), |
56 | h('section.blog', markdown(blog)), |
57 | comments, |
58 | ]), |
59 | ]) |
60 | } |
61 | } |
62 | |
63 |
Built with git-ssb-web