const crypto = require('crypto'); const { Component, Fragment } = require('inferno'); const { cacheComponent } = require('../util/cache'); class Gitalk extends Component { render() { const { id, repo, owner, admin, clientId, clientSecret, createIssueManually = false, distractionFreeMode = false, pagerDirection = 'last', perPage = 10, proxy, flipMoveOptions, enableHotKey, jsUrl, cssUrl } = this.props; if (!id || !repo || !owner || !admin || !clientId || !clientSecret) { return
You forgot to set the owner, admin, repo, client_id, or client_secret for Gitalk. Please set it in _config.yml.
; } const js = `var gitalk = new Gitalk({ id: '${id}', repo: '${repo}', owner: '${owner}', clientID: '${clientId}', clientSecret: '${clientSecret}', admin: ${JSON.stringify(admin)}, createIssueManually: ${createIssueManually}, distractionFreeMode: ${distractionFreeMode}, perPage: ${perPage}, pagerDirection: '${pagerDirection}', ${proxy ? `proxy: '${proxy}',` : ''} ${flipMoveOptions ? `flipMoveOptions: ${JSON.stringify(flipMoveOptions)},` : ''} enableHotKey: ${enableHotKey ? !!enableHotKey : true} }) gitalk.render('comment-container')`; return
; } } module.exports = cacheComponent(Gitalk, 'comment.gitalk', props => { const { helper, comment } = props; // FIXME: config name change const id = crypto.createHash('md5').update(props.page.path).digest('hex'); return { id, repo: comment.repo, owner: comment.owner, admin: comment.admin, clientId: comment.client_id, clientSecret: comment.client_secret, createIssueManually: comment.create_issue_manually, distractionFreeMode: comment.distraction_free_mode, pagerDirection: comment.pager_direction, perPage: comment.per_page, proxy: comment.proxy, flipMoveOptions: comment.flip_move_options, enableHotKey: comment.enable_hotkey, cssUrl: helper.cdn('gitalk', '1.4.1', 'dist/gitalk.css'), jsUrl: helper.cdn('gitalk', '1.4.1', 'dist/gitalk.min.js') }; });