hexo-theme-amane/layout/common/comment.jsx

33 lines
1.1 KiB
React
Raw Normal View History

2024-02-03 08:02:38 +00:00
const createLogger = require('hexo-log');
2019-12-23 21:18:59 +00:00
const { Component } = require('inferno');
const view = require('hexo-component-inferno/lib/core/view');
2019-12-23 21:18:59 +00:00
const logger = createLogger.default();
2024-02-03 08:02:38 +00:00
2019-12-23 21:18:59 +00:00
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;
}
return <div class="card">
<div class="card-content">
<h3 class="title is-5">{__('article.comments')}</h3>
2019-12-23 21:18:59 +00:00
{(() => {
try {
let Comment = view.require('comment/' + comment.type);
Comment = Comment.Cacheable ? Comment.Cacheable : Comment;
2019-12-23 21:18:59 +00:00
return <Comment config={config} page={page} helper={helper} comment={comment} />;
} catch (e) {
logger.w(`Icarus cannot load comment "${comment.type}"`);
2019-12-23 21:18:59 +00:00
return null;
}
})()}
</div>
</div>;
}
};