繁体   English   中英

Ghost 1.0 Disqus评论数未反映帖子评论

[英]Ghost 1.0 Disqus Comment Count Not Reflecting the Post Comments

我最近将Ghost版本从0.11.11更新为1.12.0

我还根据Disqus-JavaScript配置变量添加了PAGE_IDENTIFIER

索引页面上的评论计数不反映帖子的评论。

链接显示每个帖子的主页评论计数,特别是Firefox的帖子为0条评论

链接显示Firefox发帖,其中Disqus评论数为4。

以下是我当前的评论脚本

<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. GitHub上的jnowland Gist解构了count.js文件,似乎必须定义DISQUSWIDGETS.forum才能设置正确的详细信息以检索计数。

根据GitHub Gist上jnowland的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>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM