add duoshuo comment widget

This commit is contained in:
ppoffice 2015-04-04 19:41:01 +08:00
parent fbbf09a0d7
commit 234771d06c
3 changed files with 29 additions and 3 deletions

View File

@ -60,7 +60,7 @@ time_format: HH:mm:ss
# Pagination
## Set per_page to 0 to disable pagination
per_page: 10
per_page: 6
pagination_dir: page
# Extensions
@ -69,9 +69,15 @@ pagination_dir: page
theme: icarus
# Disqus
disqus_shortname:
# disqus_shortname: hexo-theme-icarus
# DuoShuo
# duoshuo_shortname: hexo-theme-icarus
# Deployment
## Docs: http://hexo.io/docs/deployment.html
deploy:
type:
type: git
repository: https://github.com/ppoffice/hexo-theme-icarus.git
branch: gh-pages

View File

@ -10,6 +10,18 @@
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<% } else if (config.duoshuo_shortname){ %>
<script type="text/javascript">
var duoshuoQuery = {short_name:"<%= config.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>
<% } %>
<script src="//ajax.useso.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>

View File

@ -26,6 +26,8 @@
<a data-url="<%- post.permalink %>" data-id="<%= post._id %>" class="article-share-link"><%= __('article.share') %></a>
<% if (post.comments && config.disqus_shortname){ %>
<a href="<%- post.permalink %>#disqus_thread" class="article-comment-link"><%= __('article.comments') %></a>
<% } else if (post.comments && config.duoshuo_shortname){ %>
<a href="<%- post.permalink %>#ds-thread" class="article-comment-link"><%= __('article.comments') %></a>
<% } %>
<%- partial('post/tag') %>
</footer>
@ -41,4 +43,10 @@
<noscript>Please enable JavaScript to view the <a href="//disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
</div>
</section>
<% } else if (!index && post.comments && config.duoshuo_shortname){ %>
<section id="comments">
<div id="ds-thread" class="ds-thread" data-thread-key="<%- post.permalink %>" data-title="<%- post.title %>" data-url="<%- post.permalink %>">
<noscript>Please enable JavaScript to view the <a href="//disqus.com/?ref_noscript">comments powered by DuoShuo.</a></noscript>
</div>
</section>
<% } %>