Sfoglia il codice sorgente

fix: comment counter issue & no document scroll listening when no sidebar

ppoffice 9 anni fa
parent
commit
bcabdd87dd
2 ha cambiato i file con 18 aggiunte e 16 eliminazioni
  1. 3 3
      layout/comment/counter.ejs
  2. 15 13
      source/js/main.js

+ 3 - 3
layout/comment/counter.ejs

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

+ 15 - 13
source/js/main.js

@@ -33,20 +33,22 @@
     });
 
     // To Top
-    $(document).on('scroll', function () {
-        if ($(document).width() >= 800) {
-            if(($(this).scrollTop() > toTop) && ($(this).scrollTop() > 0)) {    
-                $('#toTop').fadeIn();
-                $('#toTop').css('left', $('#sidebar').offset().left);
+    if ($('#sidebar').length) {
+        $(document).on('scroll', function () {
+            if ($(document).width() >= 800) {
+                if(($(this).scrollTop() > toTop) && ($(this).scrollTop() > 0)) {
+                    $('#toTop').fadeIn();
+                    $('#toTop').css('left', $('#sidebar').offset().left);
+                } else {
+                    $('#toTop').fadeOut();
+                }
             } else {
-                $('#toTop').fadeOut();
+                $('#toTop').fadeIn();
+                $('#toTop').css('right', 20);
             }
-        } else {
-            $('#toTop').fadeIn();
-            $('#toTop').css('right', 20);
-        }
-    }).on('click', '#toTop', function () {
-        $('body, html').animate({ scrollTop: 0 }, 600);
-    });
+        }).on('click', '#toTop', function () {
+            $('body, html').animate({ scrollTop: 0 }, 600);
+        });
+    }
 
 })(jQuery);