Files: 9de2656efd585098ef7eb72d618684bd03e34c37 / app / page / blogShow.js
1958 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.blogNav': 'first', |
13 | 'app.html.comments': 'first', |
14 | 'app.html.context': 'first', |
15 | 'contact.html.follow': 'first', |
16 | 'message.html.channel': 'first', |
17 | 'message.html.markdown': 'first', |
18 | 'message.html.timeago': 'first', |
19 | 'feed.obs.thread': 'first' |
20 | }) |
21 | |
22 | exports.create = (api) => { |
23 | return nest('app.page.blogShow', blogShow) |
24 | |
25 | function blogShow (blogMsg) { |
26 | // blogMsg = a thread (message, may be decorated with replies) |
27 | |
28 | const { author, content } = blogMsg.value |
29 | |
30 | const blog = content.text |
31 | const title = api.message.html.markdown(content.title || getTitle(blog)) |
32 | |
33 | const comments = api.app.html.comments(blogMsg.key) |
34 | |
35 | const { lastId: branch } = api.feed.obs.thread(blogMsg.key) |
36 | |
37 | const { timeago, channel, markdown, compose } = api.message.html |
38 | |
39 | return h('Page -blogShow', [ |
40 | api.app.html.context({ page: 'discover' }), // HACK to highlight discover |
41 | h('div.content', [ |
42 | h('section.top', [ |
43 | api.app.html.blogNav(location) |
44 | ]), |
45 | h('section.content', [ |
46 | h('header', [ |
47 | h('div.blog', [ |
48 | h('h1', title), |
49 | timeago(blogMsg), |
50 | channel(blogMsg) |
51 | ]), |
52 | h('div.author', [ |
53 | h('div.leftCol', api.about.html.avatar(author, 'medium')), |
54 | h('div.rightCol', [ |
55 | h('div.name', api.about.obs.name(author)), |
56 | api.contact.html.follow(author) |
57 | ]), |
58 | ]) |
59 | ]), |
60 | h('div.break', h('hr')), |
61 | h('section.blog', markdown(blog)), |
62 | comments, |
63 | ]), |
64 | ]) |
65 | ]) |
66 | } |
67 | } |
68 | |
69 |
Built with git-ssb-web