使用多说评论
网站的评论功能使用多说( http://duoshuo.com/ )。
考虑到Disqus
在国内基本访问不到,所以还是把评论功能换成国内能访问的较常用的多说(duoshuo)
(使用微信、微博、QQ、人人、豆瓣、开心、百度、谷歌的账号登录)吧。
此外Comm(ent|it)
( https://commentit.io/ )似乎也是个不错的选择(使用github, facebook, twitter账号登录),但对hexo开发者来说可能不太适用。
使用多说评论
注册账号,然后填入网站相关内容,之后会提示把以下代码复制并粘帖到您网页代码<body>
与</body>
间的任意位置。
1 | <!-- 多说评论框 start --> |
对于hexo用户
对hexo用户,可以使用以下代码:
1 | <!-- 多说评论框 start --> |
对tranquilpeak主题来说,可作如下修改:
在
/themes/tranquilpeak/layout/_partial/script.ejs
中加入
1
2
3
4
5
6
7
8
9
10
11
12
13<% if (theme.duoshuo_shortname && is_post() && post.comments) { %>
<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>
<% } %>修改
themes/tranquilpeak/layout/_partial/post.ejs
1
2
3
4
5
6<div class="post-footer main-content-wrap">
<%- partial('post/actions') %>
<% if (post.comments && theme.duoshuo_shortname) { %>
<%- partial('post/duoshuo') %>
<% } %>
</div>修改
themes/tranquilpeak/layout/_partial/post/actions.ejs
1
<a class="post-action-btn btn btn--default" href="#ds-thread">
在
themes/tranquilpeak/_config.yml
中加入
1
duoshuo_shortname: 你的多说shortname
添加
themes/tranquilpeak/layout/_partial/post/duoshuo.ejs
1
2<div class="ds-thread" data-thread-key="<%= post.layout %>-<%= post.slug %>" data-title="<%= post.title %>" data-url="<%= page.permalink %>">
</div>