【问题标题】:Ghost 1.0 Disqus Comment Count Not Reflecting the Post CommentsGhost 1.0 Disqus 评论计数不反映帖子评论
【发布时间】:2018-03-20 05:11:05
【问题描述】:

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

我还根据Disqus - JavaScript configuration variables 添加了一个 PAGE_IDENTIFIER

索引页面上的评论数未反映帖子 cmets。

link 显示每个帖子的主页评论计数,特别是 Firefox 的帖子是 0 cmets

这个link 显示了Disqus 评论数为4 的Firefox 帖子。

以下是我当前的 cmets 脚本

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

【问题讨论】:

    标签: javascript html handlebars.js disqus ghost


    【解决方案1】:

    根据 GitHub Gist 上 jnowland 的 count.js 文件,disqus_shortname 必须在执行 Disqus 评论计数脚本之前声明和定义。

    这将正确设置 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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-08-07
      • 2014-02-13
      • 1970-01-01
      • 2015-10-11
      • 1970-01-01
      • 2013-12-12
      • 2022-01-10
      • 2013-09-10
      相关资源
      最近更新 更多