'use strict'; const moment = require('moment'); const { Component, Fragment } = require('inferno'); const Share = require('./share'); const Donates = require('./donates'); const Comment = require('./comment'); /** * Get the word count of a paragraph. */ function getWordCount(content) { content = content.replace(/<\/?[a-z][^>]*>/gi, ''); content = content.trim(); return content ? (content.match(/[\u00ff-\uffff]|[a-zA-Z]+/g) || []).length : 0; } module.exports = class extends Component { render() { const { config, helper, page, index } = this.props; const { article, plugins } = config; const { has_thumbnail, get_thumbnail, url_for, date, date_xml, __, _p } = helper; const language = page.lang || page.language || config.language || 'en'; return {/* Main content */}
{/* Thumbnail */} {has_thumbnail(page) ?
{index ? {page.title : {page.title }
: null} {/* Metadata */}
{page.layout !== 'page' ?
{/* Date */} {/* Categories */} {page.categories && page.categories.length ?
{(() => { const categories = []; page.categories.forEach((category, i) => { categories.push({category.name}); if (i < page.categories.length - 1) { categories.push('/'); } }); return categories; })()}
: null} {/* Read time */} {article && article.readtime && article.readtime === true ? {(() => { const words = getWordCount(page._content); const time = moment.duration((words / 150.0) * 60, 'seconds'); return `${time.locale(language).humanize()} ${__('article.read')} (${__('article.about')} ${words} ${__('article.words')})`; })()} : null} {/* Visitor counter */} {plugins && plugins.busuanzi === true ? 0') }}> : null}
: null} {/* Title */}

{index ? {page.title} : page.title}

{/* Content/Excerpt */}
{index && page.excerpt ? page.excerpt : page.content}
{/* Tags */} {!index && Array.isArray(page.tags) && page.tags.length ?
# {page.tags.map(tag => { return ; })}
: null} {/* "Read more" button */} {index && page.excerpt ?
: null} {/* Share button */} {!index ? : null}
{/* Donate button */} {!index ? : null} {/* Post navigation */} {!index && (page.prev || page.next) ?
{page.prev ?
{page.prev.title}
: null} {page.next ?
{page.next.title}
: null}
: null} {/* Comment */} {!index ? : null}
; } };