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