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