tranquilpeak是Hexo的主题,目前版本是1.2.0,由于其自带的评论框架是Disqus,在国内的环境可能会加载较慢,可以修改为适应国情的多说。

themes/tranquilpeak/layout/_partial/post.ejs中找到如下代码:

1
2
3
<% if (post.comments && theme.disqus_shortname) { %>
<%- partial('post/disqus') %>
<% } %>

修改成

1
2
3
<% if (post.comments && theme.duoshuo_shortname) { %>
<%- partial('post/duoshuo') %>
<% } %>

然后在themes/tranquilpeak/layout/_partial/post目录下新建duoshuo.ejs, 添加多说的通用代码并做如下的修改:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<section id="comments">
<!-- 多说评论框 start -->
<div class="ds-thread" data-thread-key="<%= post.layout %>-<%= post.slug %>" data-title="<%= post.title %>" data-url="<%= page.permalink %>"></div>
<!-- 多说评论框 end -->
<!-- 多说公共JS代码 start (一个网页只需插入一次) -->
<script type="text/javascript">
var duoshuoQuery = {short_name:'<%= theme.duoshuo_shortname %>'};
(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>
<!-- 多说公共JS代码 end -->
</section>

最后在tranquilpeak主题的根目录下的_config.yml中增加duoshuo_shortname字段即可.

1
2
3
4
5
# Integrated services
# Your Disqus shortname
disqus_shortname:
#duoshuo
duoshuo_shortname: xxxxxx

其中xxxxxx是你在注册多说的多说域名字段,可在注册生成的多说通用代码中看到.