var h = require('mutant/h') var nest = require('depnest') var extend = require('xtend') exports.needs = nest({ 'message.html': { decorate: 'reduce', layout: 'first', link: 'first', markdown: 'first' } }) exports.gives = nest('message.html.render') exports.create = function (api) { return nest('message.html.render', function renderMessage (msg, opts) { if (msg.value.content.type !== 'post') return var element = api.message.html.layout(msg, extend({ title: messageTitle(msg), content: msg.isBlocked ? 'Content of a blocked user' : messageContent(msg), layout: 'default' }, opts)) return api.message.html.decorate(element, { msg }) }) function messageContent (data) { if (!data.value.content || !data.value.content.text) return return h('div', {}, api.message.html.markdown(data.value.content)) } function messageTitle (data) { var root = data.value.content && data.value.content.root return !root ? null : h('span', ['re: ', api.message.html.link(root)]) } }