集成多说

多说是一款追求极致体验的社会化评论框….

在 hexo 的另一款主题 hexo-material 中,发现了一些集成服务,比如多说。为博客增加评论功能还真是简单。

我现在使用的主题是 aero-dual,参考(copy) hexo-material 修改了 aero-dual 中的 3 个文件,实现了集成多说评论。

  • 一、aero-dual/_config.yml 文件末尾后增加:
1
2
3
4
5
6
7
8
# Comment Systems
# Available value:
# duoshuo
comment:
use: duoshuo
shortname:
duoshuo_thread_key: path
duoshuo_embed_js_url: "https://static.duoshuo.com/embed.js"
  • 二、aero-dual/layout/_partial/after-footer.ejs 文件末尾增加:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<% if(theme.comment.use == "duoshuo"){ %>
<!-- 多说公共 js 代码 start -->
<script type="text/javascript">
var duoshuoQuery = {short_name:"<%= theme.comment.shortname %>"};
(function() {
var ds = document.createElement('script');
ds.type = 'text/javascript';ds.async = true;
ds.src = '<%= theme.comment.duoshuo_embed_js_url %>';
ds.charset = 'UTF-8';
(document.getElementsByTagName('head')[0]
|| document.getElementsByTagName('body')[0]).appendChild(ds);
})();
</script>
<!-- 多说公共 js 代码 end -->
<% } %>
  • 三、aero-dual/layout/_partial/post/article.ejs 文件的 article 标签内 append 下面的代码:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<% if(theme.comment.use == "duoshuo"){ %>
<!-- Comment Number -->
<div class="container typo">
<div class="row">
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
<div class="ds-thread"
data-thread-key="<%= page.path %>"
data-title="<%= page.title %>"
data-url="<%= page.permalink %>">
</div>
</div>
</div>
</div>
<% } %>