|
| 1 | +<% if (theme.comment.enable) { %> |
| 2 | + <div id="gitalk-container"></div> |
| 3 | +<% } %> |
| 4 | + |
| 5 | +<% if (theme.comment.enable && theme.comment.system === 'gitalk') { %> |
| 6 | + <link rel="stylesheet" href="<%= css_link('gitalk') %>"/> |
| 7 | + <script src="<%= js_link('gitalk') %>"></script> |
| 8 | + <script> |
| 9 | + const config = <%- JSON.stringify(theme.comment.config.gitalk) %>; |
| 10 | + const gitalk = new Gitalk({ |
| 11 | + clientID: '<%= config.clientId %>', |
| 12 | + clientSecret: '<%= config.clientSecret %>', |
| 13 | + repo: '<%= config.repository %>', |
| 14 | + owner: '<%= config.owner %>', |
| 15 | + admin: ['<%= config.owner %>'], |
| 16 | + id: location.pathname.slice(1, location.pathname.lastIndexOf('/')).substring(0, 49), // Ensure uniqueness and length less than 50 |
| 17 | + distractionFreeMode: false, // Facebook-like distraction free mode |
| 18 | + createIssueManually: <%= config.createIssueManually %> |
| 19 | + }); |
| 20 | +
|
| 21 | + gitalk.render('gitalk-container') |
| 22 | +
|
| 23 | + </script> |
| 24 | +<% } %> |
| 25 | + |
| 26 | + |
| 27 | +<% if (theme.comment.enable && theme.comment.system === 'twikoo') { %> |
| 28 | +<script> |
| 29 | + (function () { |
| 30 | + const jq = document.createElement('script'); |
| 31 | + jq.src = "<%= js_link('twikoo') %>"; |
| 32 | + document.getElementsByTagName('body')[0].appendChild(jq); |
| 33 | +
|
| 34 | + const config = <%- JSON.stringify(theme.comment.config.twikoo) %>; |
| 35 | + jq.onload = function () { |
| 36 | + twikoo.init({ |
| 37 | + envId: config.envId, |
| 38 | + el: '#gitalk-container', |
| 39 | + region: config.region, |
| 40 | + path: location.pathname + (config.mark ? '?mark=' + config.mark : ''), |
| 41 | + lang: "<%= config.language %>", |
| 42 | + }); |
| 43 | + } |
| 44 | + })() |
| 45 | +</script> |
| 46 | +<% } %> |
0 commit comments