git ssb

2+

mixmix / ticktack



Tree: 354bcc491180e33154ea042ff61d5912ae2d95ab

Files: 354bcc491180e33154ea042ff61d5912ae2d95ab / app / page / blogShow.js

2038 bytesRaw
1const nest = require('depnest')
2const { h, computed, when } = require('mutant')
3const { title: getTitle } = require('markdown-summary')
4const last = require('lodash/last')
5const get = require('lodash/get')
6
7exports.gives = nest('app.page.blogShow')
8
9exports.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
23exports.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