我试图将Disqus用于我使用Flask和Flask-flatpages制作的博客网站的评论平台。
我遇到的问题是我尝试使用Jinja2变量作为评论页面标识符(对于disqus),为单独的帖子设置单独的评论主题,但我没有这样做。我不能让disqus分别为每个帖子工作,并且还有一个工作评论计数器。
我设置了我的博客,以便为我的博客文章设置降价页面(.md),并使用python markdown将帖子渲染到post.html
,如下所示:
{% extends 'base.html %}
{% block content %}
..lines of code..
{{ blog }} //var name for my blog posts
<div id="disqus_thread"></div>
<script>
/**
* RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
* LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables*/
/*
var disqus_config = function () {
this.page.url = PAGE_URL; // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = PAGE_IDENTIFIER; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};
*/
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = '//EXAMPLE.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<script id="dsq-count-scr" src="//EXAMPLE.disqus.com/count.js" async></script>
{% endblock %}
这是嵌入Disqus通用代码的正确方法吗?如果是这样,我如何传递Jinja2变量(即{{ blog.meta.id}}
)作为JS标识符变量?
由于