搭建多说评论

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
配置文件中  hexo/_config.yml

# Disqus
disqus_shortname: vingojw #写上多说的id

然后在after-footer.ejs 中加上

<% if (config.disqus_shortname){ %>
<section id="comment">
<script type="text/javascript">
var duoshuoQuery = {short_name:"vingojw"};
(function() {
var ds = document.createElement('script');
ds.type = 'text/javascript';ds.async = true;
ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
ds.charset = 'UTF-8';
(document.getElementsByTagName('head')[0]
|| document.getElementsByTagName('body')[0]).appendChild(ds);
})();
</script>
</section>
<% } %>

再找到.\themes\landscape\layout\_partial\article.ejs 中的<footer class="article-footer">.......</footer>
修改其内容为
<footer class="article-footer">
<% if (!index && post.comments && config.disqus_shortname){ %> //不是首页显示多说评论框
<!-- Duoshuo Comment BEGIN -->
<a name="comments"></a>
<div class="ds-thread" data-thread-key="<%= post.path %>" data-title="<%= post.title %>" data-url="<%= post.permalink %>"></div>
<!-- Duoshuo Comment END -->
<% } else { %> //是首页则显示评论条数
<a href="<%= post.permalink %>" class="ds-thread-count comment-link alignright" data-thread-key="<%= post.path %>" data-count-type="comments"></a>

<% } %>
<%- partial('post/tag') %>
</footer>