Kingour's Blog

追寻

如何在OpooPress中配置多说插件

| 评论

配置文件

在配置文件config.yml中添加以下配置:

# duoshuo Comments
duoshuo_short_name: your_duoshuo_shortname

评论模板

  • 添加文件templates/post/duoshuo_thread.ftl

    <!-- Duoshuo Comment BEGIN -->
    <div class="ds-thread"></div>
    <script type="text/javascript">
    var duoshuoQuery = {short_name:"dollar{ site.duoshuo_short_name }"};
    // dollar 请手动转换为$,为了避免被OpooPress解析成博主自己的shortname使用dollar替代了$
    (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 -->
    
  • 添加文件templates/post/comments_duoshuo.ftl

    <#-- page.comments is not set or true -->
    <#if site.duoshuo_short_name?? && (page.comments)!true == true><#assign showComments = true>
    <section>
    <h1><@i18n.msg "Comments"/></h1>
    <#include "duoshuo_thread.ftl">
    </section>
    </#if>
    

修改文章发布模板

templates/_post.ftl第28行修改为

<#include "post/comments_duoshuo.ftl">

OpooPress作者已经集成了多说,请到github下载最新源码