const { Component, Fragment } = require('inferno');
const { cacheComponent } = require('../util/cache');
class DisqusJs extends Component {
render() {
const {
shortname,
apiKey,
api,
admin,
adminLabel = false,
nesting = 4,
disqusId,
path,
permalink,
pageTitle,
siteTitle,
jsUrl,
cssUrl
} = this.props;
if (!shortname) {
return
You forgot to set the shortname
or apiKey
for Disqus.
Please set it in _config.yml
.
;
}
const js = `new DisqusJS({
shortname: '${shortname}',
apikey: '${JSON.stringify(apiKey)}',
siteName: '${siteTitle}',
identifier: '${disqusId || path}',
url: '${permalink || path}',
title: '${pageTitle}',
api: '${api}',
admin: '${admin}',
adminLabel: '${adminLabel}',
nesting: ${nesting}%>
});`;
return
;
}
}
module.exports = cacheComponent(DisqusJs, 'comment.disqusjs', props => {
const { config, page, helper, comment } = props;
return {
path: page.path,
shortname: comment.shortname,
apiKey: comment.apiKey,
api: comment.api,
admin: comment.admin,
adminLabel: comment.adminLabel,
nesting: comment.nesting,
disqusId: page.disqusId,
permalink: page.permalink,
pageTitle: page.title,
siteTitle: config.title,
jsUrl: helper.cdn('disqusjs', '1.2.5', 'dist/disqus.js'),
cssUrl: helper.cdn('disqusjs', '1.2.5', 'dist/disqusjs.css')
};
});