为 Octopress 添加多说评论系统

多说( http://duoshuo.com/ )接入流程也不复杂。网上有很多教程,我简单说一下我是如何操作的。

1.获取站点的short_name

到多说的官网注册账号,并且添加你的站点。short_name就是添加站点的时候的多说域名框里填写的。添加站点流程如下:

duoshuozhuce.jpg

2.配置_config.yml

_config.yml 中添加

# duoshuo comments
duoshuo_comments: true
duoshuo_short_name: superqq

3.添加多说评论模块

打开文件 source/_layouts/post.html 找到下面这段disqus代码

{% if site.disqus_short_name and page.comments == true %}
  <section>
    <h1>Comments</h1>
    <div id="disqus_thread" aria-live="polite">{% include post/disqus_thread.html %}</div>
  </section>
{% endif %}

在下面增加:

{% if site.duoshuo_short_name and site.duoshuo_comments == true and page.comments == true %}
  <section>
    <h1>Comments</h1>
    <div id="comments" aria-live="polite">{% include post/duoshuo.html %}</div>
  </section>
{% endif %}

4.创建duoshuo.html

创建一个source/_includes/post/duoshuo.html,里面实现代码如下:

<!-- Duoshuo Comment BEGIN -->
<div class="ds-thread" data-title="{% if site.titlecase %}{{ page.title | titlecase }}{% else %}{{ page.title }}{% endif %}"></div>
<script type="text/javascript">
  var duoshuoQuery = {short_name:"{{ site.duoshuo_short_name }}"};
  (function() {
    var ds = document.createElement('script');
    ds.type = 'text/javascript';ds.async = true;
    ds.src = 'http://static.duoshuo.com/embed.js';
    ds.charset = 'UTF-8';
    (document.getElementsByTagName('head')[0] 
    || document.getElementsByTagName('body')[0]).appendChild(ds);
  })();
</script>
<!-- Duoshuo Comment END -->

5.配置article.html

打开文件 _includes/article.html 文件,在

{% if site.disqus_short_name and page.comments != false and post.comments != false and site.disqus_show_comment_count == true %}
     | <a href="{% if index %}{{ root_url }}{{ post.url }}{% endif %}#disqus_thread">Comments</a>
    {% endif %}

在下面增加:

     {% if site.duoshuo_short_name and page.comments != false and post.comments != false and site.duoshuo_comments == true %}
      | <a href="{% if index %}{{ root_url }}{{ post.url }}{% endif %}#comments">Comments</a>
     {% endif %}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值