plugs/message/html/render/blog.jsView |
---|
6 | 6 | exports.gives = nest('message.html.render') |
7 | 7 | |
8 | 8 | exports.needs = nest({ |
9 | 9 | 'about.obs.color': 'first', |
| 10 | + 'app.navigate': 'first', |
10 | 11 | 'blob.sync.url': 'first', |
11 | 12 | 'message.html.decorate': 'reduce', |
12 | 13 | 'message.html.layout': 'first', |
13 | 14 | 'message.html.markdown': 'first', |
20 | 21 | function blogRenderer (msg, opts) { |
21 | 22 | if (!isBlog(msg)) return |
22 | 23 | |
23 | 24 | var blog = Blog(api.sbot.obs.connection).obs.get(msg) |
24 | | - var showBlog = Value(false) |
25 | | - |
| 25 | + var content = opts.renderAsCard |
| 26 | + ? BlogCard({ |
| 27 | + blog, |
| 28 | + onClick: () => api.app.navigate(msg.key), |
| 29 | + color: api.about.obs.color, |
| 30 | + blobUrl: api.blob.sync.url |
| 31 | + }) |
| 32 | + : BlogFull(blog, api.message.html.markdown) |
26 | 33 | |
27 | 34 | const element = api.message.html.layout(msg, Object.assign({}, { |
28 | | - content: when(showBlog, |
29 | | - BlogFull(blog, api.message.html.markdown), |
30 | | - BlogCard({ |
31 | | - blog, |
32 | | - onClick: () => showBlog.set(true), |
33 | | - color: api.about.obs.color, |
34 | | - blobUrl: api.blob.sync.url |
35 | | - }) |
36 | | - |
37 | | - ), |
| 35 | + content, |
38 | 36 | layout: 'default' |
39 | 37 | }, opts)) |
40 | 38 | |
41 | 39 | return api.message.html.decorate(element, { msg }) |