【发布时间】: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