Browse Source

fix: comment counter don't display right comment count

ppoffice 9 năm trước cách đây
mục cha
commit
d360f9662d

+ 5 - 4
_config.yml.example

@@ -9,6 +9,7 @@ menu:
 # Customize
 # Customize
 customize:
 customize:
     logo:
     logo:
+        enabled: true
         width: 40
         width: 40
         height: 40
         height: 40
         url: images/logo.png
         url: images/logo.png
@@ -17,10 +18,10 @@ customize:
         avatar: css/images/avatar.png
         avatar: css/images/avatar.png
         gravatar: # Gravatar email address, if you enable Gravatar, your avatar config will be overriden
         gravatar: # Gravatar email address, if you enable Gravatar, your avatar config will be overriden
         author: PPOffice
         author: PPOffice
-        author_title: 'Web Developer & Designer'
-        location: 'Harbin, China'
+        author_title: Web Developer & Designer
+        location: Harbin, China
         follow: https://github.com/ppoffice/
         follow: https://github.com/ppoffice/
-    highlight: androidstudio
+    highlight: monokai
     sidebar: right # sidebar position, options: left, right
     sidebar: right # sidebar position, options: left, right
     thumbnail: true # enable posts thumbnail, options: true, false
     thumbnail: true # enable posts thumbnail, options: true, false
     favicon: # path to favicon
     favicon: # path to favicon
@@ -43,7 +44,7 @@ widgets:
 # Search
 # Search
 search:
 search:
     swiftype: # enter swiftype install key here
     swiftype: # enter swiftype install key here
-    baidu: false # you need to disable other search engines to use Baidu search, options: true, false
+    baidu: true # you need to disable other search engines to use Baidu search, options: true, false
 
 
 # Comment
 # Comment
 comment:
 comment:

+ 9 - 0
layout/comment/counter.ejs

@@ -0,0 +1,9 @@
+<% if (post.comments) { %>
+    <% if (theme.comment.disqus) { %>
+        <a href="<%- post.permalink %>#comments" class="article-comment-link disqus-comment-count" data-disqus-url="<%= post.permalink %>"><%= __('article.comments') %></a>
+    <% } else if (theme.comment.duoshuo) { %>
+        <a href="<%- post.permalink %>#comments" class="article-comment-link ds-thread-count" data-thread-key="<%= post.path %>"><%= __('article.comments') %></a>
+    <% } else if (theme.comment.youyan) { %>
+        <a href="<%- post.permalink %>#comments" class="article-comment-link"><%= __('article.comments') %></a>
+    <% } %>
+<% } %>

+ 22 - 19
layout/comment/disqus.ejs

@@ -1,19 +1,22 @@
-<div id="disqus_thread">
-    <noscript>Please enable JavaScript to view the <a href="//disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
-</div>
-<script>
-var disqus_shortname = '<%= theme.comment.disqus %>';
-<% if (page.disqusId) { %>
-var disqus_identifier = '<%= page.disqusId || page.slug %>';
-<% } %>
-<% if (page.permalink) { %>
-var disqus_url = '<%= page.permalink %>';
-<% } %>
-(function() {
-var dsq = document.createElement('script');
-dsq.type = 'text/javascript';
-dsq.async = true;
-dsq.src = '//' + disqus_shortname + '.disqus.com/<% if (page.comments) { %>embed.js<% } else { %>count.js<% } %>';
-(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
-})();
-</script>
+<% if (typeof(script) !== 'undefined' && script) { %>
+    <script>
+    var disqus_shortname = '<%= theme.comment.disqus %>';
+    <% if (page.disqusId) { %>
+    var disqus_identifier = '<%= page.disqusId || page.slug %>';
+    <% } %>
+    <% if (page.permalink) { %>
+    var disqus_url = '<%= page.permalink %>';
+    <% } %>
+    (function() {
+    var dsq = document.createElement('script');
+    dsq.type = 'text/javascript';
+    dsq.async = true;
+    dsq.src = '//' + disqus_shortname + '.disqus.com/<% if (page.comments) { %>embed.js<% } else { %>count.js<% } %>';
+    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
+    })();
+    </script>
+<% } else { %>
+    <div id="disqus_thread">
+        <noscript>Please enable JavaScript to view the <a href="//disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
+    </div>
+<% } %>

+ 52 - 49
layout/comment/duoshuo.ejs

@@ -1,49 +1,52 @@
-<div class="ds-thread" data-thread-key="<%= post.layout %>-<%= post.slug %>" data-title="<%= post.title %>" data-url="<%= page.permalink %>"></div>
-<script type="text/javascript">
-var duoshuoQuery = {short_name:'<%= theme.comment.duoshuo %>'};
-(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>
-<style>
-    #ds-thread #ds-reset .ds-textarea-wrapper {
-        background: none;
-    }
-    #ds-reset .ds-avatar img {
-        box-shadow: none;
-    }
-    #ds-reset .ds-gradient-bg {
-        background: #f7f7f7;
-    }
-    #ds-thread #ds-reset li.ds-tab a {
-        border-radius: 3px;
-    }
-    #ds-thread #ds-reset .ds-post-button {
-        color: white;
-        border: none;
-        box-shadow: none;
-        background: #d32;
-        text-shadow: none;
-        font-weight: normal;
-        font-family: 'Microsoft Yahei';
-    }
-    #ds-thread #ds-reset .ds-post-button:hover {
-        color: white;
-        background: #DE594C;
-    }
-    #ds-thread #ds-reset .ds-post-button:active {
-        background: #d32;
-    }
-    #ds-smilies-tooltip ul.ds-smilies-tabs li a.ds-current {
-        color: white;
-        background: #d32;
-        box-shadow: none;
-        text-shadow: none;
-        font-weight: normal;
-    }
-</style>
+<% if (typeof(script) !== 'undefined' && script) { %>
+    <script type="text/javascript">
+    var duoshuoQuery = {short_name:'<%= theme.comment.duoshuo %>'};
+    (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>
+<% } else { %>
+    <div class="ds-thread" data-thread-key="<%= post.path %>" data-title="<%= post.title %>" data-url="<%= page.permalink %>"></div>
+    <style>
+        #ds-thread #ds-reset .ds-textarea-wrapper {
+            background: none;
+        }
+        #ds-reset .ds-avatar img {
+            box-shadow: none;
+        }
+        #ds-reset .ds-gradient-bg {
+            background: #f7f7f7;
+        }
+        #ds-thread #ds-reset li.ds-tab a {
+            border-radius: 3px;
+        }
+        #ds-thread #ds-reset .ds-post-button {
+            color: white;
+            border: none;
+            box-shadow: none;
+            background: #d32;
+            text-shadow: none;
+            font-weight: normal;
+            font-family: 'Microsoft Yahei';
+        }
+        #ds-thread #ds-reset .ds-post-button:hover {
+            color: white;
+            background: #DE594C;
+        }
+        #ds-thread #ds-reset .ds-post-button:active {
+            background: #d32;
+        }
+        #ds-smilies-tooltip ul.ds-smilies-tabs li a.ds-current {
+            color: white;
+            background: #d32;
+            box-shadow: none;
+            text-shadow: none;
+            font-weight: normal;
+        }
+    </style>
+<% } %>

+ 9 - 9
layout/comment/index.ejs

@@ -1,11 +1,11 @@
 <% if (post.comments) { %>
 <% if (post.comments) { %>
-<section id="comments">
-<% if (theme.comment.disqus) { %>
-    <%- partial('comment/disqus') %>
-<% } else if (theme.comment.duoshuo) { %>
-    <%- partial('comment/duoshuo') %>
-<% } else if (theme.comment.youyan) { %>
-    <%- partial('comment/youyan') %>
-<% } %>
-</section>
+    <section id="comments">
+    <% if (theme.comment.disqus) { %>
+        <%- partial('comment/disqus') %>
+    <% } else if (theme.comment.duoshuo) { %>
+        <%- partial('comment/duoshuo') %>
+    <% } else if (theme.comment.youyan) { %>
+        <%- partial('comment/youyan') %>
+    <% } %>
+    </section>
 <% } %>
 <% } %>

+ 7 - 0
layout/comment/scripts.ejs

@@ -0,0 +1,7 @@
+<% if (theme.comment.disqus) { %>
+    <%- partial('comment/disqus', { script: true }) %>
+<% } else if (theme.comment.duoshuo) { %>
+    <%- partial('comment/duoshuo', { script: true }) %>
+<% } else if (theme.comment.youyan) { %>
+    <%- partial('comment/youyan', { script: true }) %>
+<% } %>

+ 5 - 2
layout/comment/youyan.ejs

@@ -1,2 +1,5 @@
-<div id="uyan_frame"></div>
-<script type="text/javascript" src="http://v2.uyan.cc/code/uyan.js?uid=<%= theme.comment.youyan %>"></script>
+<% if (typeof(script) !== 'undefined' && script) { %>
+    <script type="text/javascript" src="http://v2.uyan.cc/code/uyan.js?uid=<%= theme.comment.youyan %>"></script>
+<% } else { %>
+    <div id="uyan_frame"></div>
+<% } %>

+ 1 - 5
layout/common/article.ejs

@@ -32,11 +32,7 @@
         </div>
         </div>
         <footer class="article-footer">
         <footer class="article-footer">
             <%- partial('share/index', { post: post }) %>
             <%- partial('share/index', { post: post }) %>
-            <% 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('comment/counter', { post: post }) %>
         </footer>
         </footer>
     </div>
     </div>
     <% if (!index) { %>
     <% if (!index) { %>

+ 2 - 2
layout/common/header.ejs

@@ -2,7 +2,7 @@
     <div id="header-main" class="header-inner">
     <div id="header-main" class="header-inner">
         <div class="outer">
         <div class="outer">
             <a href="<%- url_for() %>" id="logo">
             <a href="<%- url_for() %>" id="logo">
-                <%- (theme.customize.logo ? '<i class="logo"></i>':'') %>
+                <%- (theme.customize.logo && theme.customize.logo.enabled ? '<i class="logo"></i>':'') %>
                 <span class="site-title"><%= config.title %></span>
                 <span class="site-title"><%= config.title %></span>
             </a>
             </a>
             <nav id="main-nav">
             <nav id="main-nav">
@@ -10,7 +10,7 @@
                     <a class="main-nav-link" href="<%- url_for(theme.menu[i]) %>"><%= i %></a>
                     <a class="main-nav-link" href="<%- url_for(theme.menu[i]) %>"><%= i %></a>
                 <% } %>
                 <% } %>
             </nav>
             </nav>
-            <% if(theme.customize.profile) { %>
+            <% if(theme.customize.profile && theme.customize.profile.enabled) { %>
                 <nav id="sub-nav">
                 <nav id="sub-nav">
                     <div class="profile" id="profile-nav">
                     <div class="profile" id="profile-nav">
                         <a id="profile-anchor" href="javascript:;">
                         <a id="profile-anchor" href="javascript:;">

+ 1 - 1
layout/common/profile.ejs

@@ -6,7 +6,7 @@
             <h2 id="name"><%= profile.author %></h2>
             <h2 id="name"><%= profile.author %></h2>
             <h3 id="title"><%= profile.author_title %></h3>
             <h3 id="title"><%= profile.author_title %></h3>
             <span id="location"><i class="fa fa-map-marker"></i><%= profile.location %></span>
             <span id="location"><i class="fa fa-map-marker"></i><%= profile.location %></span>
-            <a id="follow" href="<%= profile.follow %>"><%= __('profile.follow') %></a>
+            <a id="follow" target="_blank" href="<%= profile.follow %>"><%= __('profile.follow') %></a>
         </div>
         </div>
         <div class="article-info profile-block">
         <div class="article-info profile-block">
             <div class="article-info-block">
             <div class="article-info-block">

+ 1 - 0
layout/common/scripts.ejs

@@ -1,3 +1,4 @@
+<%- partial('comment/scripts', { page: page }) %>
 <%- partial('plugin/scripts') %>
 <%- partial('plugin/scripts') %>
 
 
 <!-- Custom Scripts -->
 <!-- Custom Scripts -->