git ssb

2+

mixmix / ticktack



Tree: b02d5837685a7fb8e42751b875db010b8ec801c6

Files: b02d5837685a7fb8e42751b875db010b8ec801c6 / app / page / blogShow.js

2184 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 'blog.html.title': 'first',
23 'blog.html.content': 'first',
24
25})
26
27exports.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 //app.html.comments also loads the thread obs.
39 const comments = api.app.html.comments(blogMsg.key)
40
41 //loads entire thread, just to get the branch.
42 const { lastId: branch } = api.feed.obs.thread(blogMsg.key)
43
44 const { timeago, channel, markdown, compose } = api.message.html
45
46 return h('Page -blogShow', [
47 api.app.html.context({ page: 'discover' }), // HACK to highlight discover
48 h('div.content', [
49 h('section.top', [
50 api.app.html.blogNav(location)
51 ]),
52 h('section.content', [
53 h('header', [
54 h('div.blog', [
55 h('h1', title),
56 timeago(blogMsg),
57 channel(blogMsg),
58 api.message.html.likes(blogMsg)
59 ]),
60 h('div.author', [
61 h('div.leftCol', api.about.html.avatar(author, 'medium')),
62 h('div.rightCol', [
63 h('div.name', api.about.obs.name(author)),
64 api.contact.html.follow(author)
65 ]),
66 ])
67 ]),
68 h('div.break', h('hr')),
69 h('section.blog', blog),
70 comments,
71 ]),
72 ])
73 ])
74 }
75}
76
77
78

Built with git-ssb-web