Skip to content

Commit 515b543

Browse files
committed
Update Disuqs service integration
1 parent b436399 commit 515b543

File tree

4 files changed

+24
-30
lines changed

4 files changed

+24
-30
lines changed

_config.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,10 @@ mathjax:
292292
#duoshuo_shortname:
293293

294294
# Disqus
295-
#disqus_shortname:
295+
disqus:
296+
enable: false
297+
shortname:
298+
count: true
296299

297300
# Hypercomments
298301
#hypercomments_id:

layout/_macro/post.swig

+3-2
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,15 @@
134134
<span class="post-comments-count fb-comments-count" data-href="{{ post.permalink }}" itemprop="commentCount">0</span> comments
135135
</a>
136136
</span>
137-
{% elseif theme.disqus_shortname %}
137+
{% elseif theme.disqus.enable and theme.disqus.count %}
138138
<span class="post-comments-count">
139139
<span class="post-meta-divider">|</span>
140140
<span class="post-meta-item-icon">
141141
<i class="fa fa-comment-o"></i>
142142
</span>
143143
<a href="{{ url_for(post.path) }}#comments" itemprop="discussionUrl">
144-
<span class="post-comments-count disqus-comment-count" data-disqus-identifier="{{ post.path }}" itemprop="commentCount"></span>
144+
<span class="post-comments-count disqus-comment-count"
145+
data-disqus-identifier="{{ post.path }}" itemprop="commentCount"></span>
145146
</a>
146147
</span>
147148
{% elseif theme.hypercomments_id %}

layout/_partials/comments.swig

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
</div>
1414
{% elseif theme.vkontakte_api.enable and theme.vkontakte_api.comments %}
1515
<div id="vk_comments"></div>
16-
{% elseif theme.disqus_shortname %}
16+
{% elseif theme.disqus.enable %}
1717
<div id="disqus_thread">
1818
<noscript>
1919
Please enable JavaScript to view the
20-
<a href="//disqus.com/?ref_noscript">comments powered by Disqus.</a>
20+
<a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a>
2121
</noscript>
2222
</div>
2323
{% elseif theme.hypercomments_id %}
+15-25
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,23 @@
11
{% if not (theme.duoshuo and theme.duoshuo.shortname) and not theme.duoshuo_shortname %}
2+
{% if theme.disqus.enable %}
23

3-
{% if theme.disqus_shortname %}
4+
{% if theme.disqus.count %}
5+
<script id="dsq-count-scr" src="https://{{theme.disqus.shortname}}.disqus.com/count.js" async></script>
6+
{% endif %}
47

5-
<script type="text/javascript">
6-
var disqus_shortname = '{{theme.disqus_shortname}}';
7-
var disqus_identifier = '{{ page.path }}';
8-
9-
var disqus_title = "{{ page.title|addslashes }}";
10-
11-
12-
function run_disqus_script(disqus_script) {
13-
var dsq = document.createElement('script');
14-
dsq.type = 'text/javascript';
15-
dsq.async = true;
16-
dsq.src = '//' + disqus_shortname + '.disqus.com/' + disqus_script;
17-
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
18-
}
19-
20-
run_disqus_script('count.js');
21-
22-
{% if page.comments %}
8+
{% if page.comments %}
9+
<script type="text/javascript">
2310
var disqus_config = function () {
24-
this.page.url = disqus_url;
25-
this.page.identifier = disqus_identifier;
26-
this.page.title = disqus_title;
11+
this.page.url = '{{ page.permalink }}';
12+
this.page.identifier = '{{ page.path }}';
13+
this.page.title = '{{ page.title| addslashes }}';
2714
};
28-
run_disqus_script('embed.js');
29-
{% endif %}
15+
var d = document, s = d.createElement('script');
16+
s.src = 'https://{{theme.disqus.shortname}}.disqus.com/embed.js';
17+
s.setAttribute('data-timestamp', '' + +new Date());
18+
(d.head || d.body).appendChild(s);
19+
</script>
20+
{% endif %}
3021

31-
</script>
3222
{% endif %}
3323
{% endif %}

0 commit comments

Comments
 (0)