Parcourir la source

add duoshuo comment widget

ppoffice il y a 10 ans
Parent
commit
234771d06c
3 fichiers modifiés avec 29 ajouts et 3 suppressions
  1. 9 3
      _config.yml.site.example
  2. 12 0
      layout/_partial/after-footer.ejs
  3. 8 0
      layout/_partial/article.ejs

+ 9 - 3
_config.yml.site.example

@@ -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

+ 12 - 0
layout/_partial/after-footer.ejs

@@ -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>

+ 8 - 0
layout/_partial/article.ejs

@@ -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>
 <% } %>