配置文件
在配置文件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">