UNPKG

hexo-theme-amazing

Version:

A simple, delicate, and modern theme for Hexo

44 lines (40 loc) 1.82 kB
const logger = require('hexo-log')(); const {Component} = require('inferno'); const view = require('hexo-component-inferno/lib/core/view'); module.exports = class extends Component { render() { const {config, page, helper} = this.props; const {__} = helper; const {comment} = config; if (!comment || typeof comment.type !== 'string') { return null; } const isGitalk = comment.type == 'gitalk'; const commentColsed = !page.comments; return <div class="card"> <div class="card-content"> {!commentColsed ? <div class="title is-5">{__('article.comments')}</div> : null} {(() => { try { if (isGitalk || !commentColsed) { let Comment = view.require('comment/' + comment.type); Comment = Comment.Cacheable ? Comment.Cacheable : Comment; return <Comment config={config} page={page} helper={helper} comment={comment}/>; } else { return <Fragment> <div id="comment-container"> <div class="gt-container"> <h3 class="menu-label has-text-centered">{__('article.comments_closed')}</h3> </div> </div> </Fragment>; } } catch (e) { logger.w(`Icarus cannot load comment "${comment.type}"`); return null; } })()} </div> </div>; } };