-
Notifications
You must be signed in to change notification settings - Fork 0
/
disqus.ejs
42 lines (39 loc) · 1.7 KB
/
disqus.ejs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<% const comment_config = theme.social && theme.social.comment && theme.social.comment.disqus %>
<% const disqus_shortname = comment_config && env.env === 'production' ? comment_config.shortname : '' %>
<% if (comment_config && disqus_shortname) { %>
<% const page_url = page.permalink %>
<% const page_id = page_url.replace(config.url, '') %>
<div id="disqus_thread"></div>
<% if (comment_config.proxy) { %>
<%- js('javascripts/ksio/vendors/disqusjs.min') %>
<script>
var dsqjs = new DisqusJS({
shortname: '<%= disqus_shortname %>',
siteName: '<%= config.title %>',
identifier: '<%= page_id %>',
url: '<%= page_url %>',
title: '<%= page.title %>',
api: '<%= comment_config.proxy.endpoint %>',
apikey: '<%= comment_config.proxy.key %>',
admin: '<%= comment_config.username %>',
adminLabel: '<%= comment_config.label || "管理员" %>'
});
</script>
<% } else { %>
<script>
var disqus_config = function () {
this.page.link = '<%= page_url %>';
this.page.identifier = "<%= page_id %>";
this.page.title = '<%= page.title %>';
};
(function() {
var d = document, s = d.createElement('script');
s.src = '//<%= disqus_shortname %>.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="external ">comments powered by Disqus.</a></noscript>
<script id="dsq-count-scr" src="//<%= disqus_shortname %>.disqus.com/count.js" async></script>
<% } %>
<% } %>