1 | (function () {
|
2 | var fixedPath = location.href.replace('/-/', '/#/');
|
3 | if (fixedPath !== location.href) {
|
4 | location.href = fixedPath;
|
5 | }
|
6 |
|
7 | function install(hook, vm) {
|
8 | var dom = Docsify.dom;
|
9 | var disqus = vm.config.disqus;
|
10 | if (!disqus) {
|
11 | throw Error('$docsify.disqus is required')
|
12 | }
|
13 |
|
14 | hook.init(function (_) {
|
15 | var script = dom.create('script');
|
16 |
|
17 | script.async = true;
|
18 | script.src = "https://" + disqus + ".disqus.com/embed.js";
|
19 | script.setAttribute('data-timestamp', Number(new Date()));
|
20 | dom.appendTo(dom.body, script);
|
21 | });
|
22 |
|
23 | hook.mounted(function (_) {
|
24 | var div = dom.create('div');
|
25 | div.id = 'disqus_thread';
|
26 | var main = dom.getNode('#main');
|
27 | div.style = "width: " + (main.clientWidth) + "px; margin: 0 auto 20px;";
|
28 | dom.appendTo(dom.find('.content'), div);
|
29 |
|
30 |
|
31 | window.disqus_config = function() {
|
32 | this.page.url = location.origin + '/-' + vm.route.path;
|
33 | this.page.identifier = vm.route.path;
|
34 | this.page.title = document.title;
|
35 | };
|
36 | });
|
37 |
|
38 | hook.doneEach(function (_) {
|
39 | if (typeof window.DISQUS !== 'undefined') {
|
40 | window.DISQUS.reset({
|
41 | reload: true,
|
42 | config: function () {
|
43 | this.page.url = location.origin + '/-' + vm.route.path;
|
44 | this.page.identifier = vm.route.path;
|
45 | this.page.title = document.title;
|
46 | }
|
47 | });
|
48 | }
|
49 | });
|
50 | }
|
51 |
|
52 | $docsify.plugins = [].concat(install, $docsify.plugins);
|
53 |
|
54 | }());
|