我最近将 Ghost 版本从 0.11.11 更新为 1.12.0
我还根据Disqus - JavaScript configuration variables
添加了PAGE_IDENTIFIER索引页面上的评论计数不反映帖子评论。
此link显示每篇帖子的主页评论计数,特别是Firefox的帖子 0条评论
此link显示带有Disqus评论数为4的Firefox帖子。
以下是我当前的评论脚本
<script type="text/javascript">
/* * * DON'T EDIT BELOW THIS LINE * * */
(function () {
var s = document.createElement('script');
s.async = true;
s.type = 'text/javascript';
s.src = '//' + disqus.shortname + '.disqus.com/count.js';
(document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
}());
</script>
我正在使用以下内容创建评论计数链接
<i class="fa fa-comment-o"></i> <a href="{{url absolute="true"}}#disqus_thread" data-disqus-identifier="{{comment_id}}">Comments</a>
帖子评论脚本如下
<script type="text/javascript">
var disqus_config = function () {
this.page.url = '{{url absolute="true"}}';
this.page.identifier = '{{comment_id}}';
this.page.title = '{{title}}';
};
/* * * DON'T EDIT BELOW THIS LINE * * */
(function () {
var dsq = document.createElement('script');
dsq.type = 'text/javascript';
dsq.async = true;
dsq.src = '//' + disqus.shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
问题的
我最近使用映射器更新了URL链接,但是这会获取新的page.identifier
吗?
如果没有,我可以采取哪些措施来修复评论计数?
研究
1。 count.js
文件确实已加载,因为加载后链接文本正在被替换。
2. 我发现加载Disqus计数脚本时会创建一个名为DISQUSWIDGETS的对象。 DISQUSWIDGETS.forum字段未定义。
3. Jnowland在GitHub上Gist解构了count.js文件,似乎必须定义DISQUSWIDGETS.forum才能设置正确的详细信息来检索计数。
答案 0 :(得分:1)
根据jnowland在GitHub Gist上的count.js文件,必须在执行Disqus评论计数脚本之前声明并定义disqus_shortname
。
这将正确设置DISQUSWIDGETS.forum字段。
<script type="text/javascript">
var disqus_shortname = "MY_SHORTNAME"; // Replace MY_SHORTNAME with your DISQUS shortname.
/* * * DON'T EDIT BELOW THIS LINE * * */
(function () {
var s = document.createElement('script');
s.async = true;
s.type = 'text/javascript';
s.src = '//' + disqus_shortname + '.disqus.com/count.js';
(document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
}());
</script>