docsify/lib/plugins/gitalk.js

21 lines
558 B
JavaScript
Raw Normal View History

2017-11-11 10:15:16 +08:00
(function () {
2018-03-03 22:57:34 +08:00
function install(hook) {
2017-11-11 10:15:16 +08:00
var dom = Docsify.dom;
hook.mounted(function (_) {
var div = dom.create('div');
div.id = 'gitalk-container';
var main = dom.getNode('#main');
div.style = "width: " + (main.clientWidth) + "px; margin: 0 auto 20px;";
dom.appendTo(dom.find('.content'), div);
var script = dom.create('script');
var content = "gitalk.render('gitalk-container')";
script.textContent = content;
dom.appendTo(dom.body, script);
});
}
$docsify.plugins = [].concat(install, $docsify.plugins);
}());