git ssb

2+

mixmix / ticktack



Tree: dfa8dcc1b8dc80fea753df44f2c9faa9c5eb88ef

Files: dfa8dcc1b8dc80fea753df44f2c9faa9c5eb88ef / app / page / blogIndex.js

1485 bytesRaw
1const nest = require('depnest')
2const { h } = require('mutant')
3const pull = require('pull-stream')
4
5exports.gives = nest('app.page.blogIndex')
6
7exports.needs = nest({
8 'app.html.context': 'first',
9 'app.html.blogCard': 'first',
10 'app.html.scroller': 'first',
11 'feed.pull.public': 'first',
12 'history.sync.push': 'first',
13 'keys.sync.id': 'first',
14 'translations.sync.strings': 'first',
15 'unread.sync.isUnread': 'first'
16})
17
18exports.create = (api) => {
19 return nest('app.page.blogIndex', function (location) {
20 // location here can expected to be: { page: 'blogIndex'} or { page: 'home' }
21
22 var strings = api.translations.sync.strings()
23
24 var blogs = api.app.html.scroller({
25 classList: ['content'],
26 prepend: h('Button -primary', { 'ev-click': () => api.history.sync.push({ page: 'blogNew' }) }, strings.blogNew.actions.writeBlog),
27 stream: api.feed.pull.public,
28 filter: () => pull(
29 pull.filter(msg => {
30 const type = msg.value.content.type
31 return type === 'post' || type === 'blog'
32 })
33 ),
34 render
35 })
36
37 return h('Page -blogIndex', {title: strings.home}, [
38 api.app.html.context(location),
39 blogs
40 ])
41 })
42
43
44
45 function render (blog) {
46 const { recps, channel } = blog.value.content
47 var onClick
48 if (channel && !recps)
49 onClick = (ev) => api.history.sync.push(Object.assign({}, blog, { page: 'blogShow' }))
50
51 return api.app.html.blogCard(blog, { onClick })
52 }
53}
54
55

Built with git-ssb-web