git ssb

2+

mixmix / ticktack



Tree: d1fb3daa34d11265fab5f4118776a40e96d39062

Files: d1fb3daa34d11265fab5f4118776a40e96d39062 / app / page / blogShow.js

1948 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.comments': 'first',
13 'app.html.context': 'first',
14 'message.html.channel': 'first',
15 'message.html.compose': 'first',
16 'message.html.markdown': 'first',
17 'message.html.timeago': 'first',
18})
19
20exports.create = (api) => {
21 return nest('app.page.blogShow', blogShow)
22
23 function blogShow (blogMsg) {
24 // blogMsg = a thread (message, may be decorated with replies)
25
26 const { author, content } = blogMsg.value
27
28 const blog = content.text
29 const title = content.title || getTitle(blog)
30
31 const comments = api.app.html.comments(blogMsg.key)
32
33 const meta = {
34 type: 'post',
35 root: blogMsg.key,
36 // branch: get(last(blogMsg.replies), 'key'), // TODO - change to match new comments logic
37 // >> lastId? CHECK THIS LOGIC
38 channel: content.channel
39 }
40
41 const { timeago, channel, markdown, compose } = api.message.html
42 const composer = compose({ meta, shrink: true })
43
44 return h('Page -blogShow', [
45 api.app.html.context({ page: 'discover' }), // HACK to highlight discover
46 h('div.content', [
47 h('header', [
48 h('div.blog', [
49 h('h1', title),
50 timeago(blogMsg),
51 channel(blogMsg)
52 ]),
53 h('div.author', [
54 h('div.leftCol', api.about.html.avatar(author, 'medium')),
55 h('div.rightCol', [
56 h('div.name', api.about.obs.name(author)),
57 h('Button', 'Follow')
58 ]),
59 ])
60 ]),
61 h('div.break', h('hr')),
62 h('section.blog', markdown(blog)),
63 composer,
64 comments,
65 ]),
66 ])
67 }
68}
69
70

Built with git-ssb-web