Browse Source

chore: add insight search hash support & fix commit counter link issue

ppoffice 9 years ago
parent
commit
99a47ee8d0
2 changed files with 7 additions and 5 deletions
  1. 3 3
      layout/comment/counter.ejs
  2. 4 2
      layout/search/insight.ejs

+ 3 - 3
layout/comment/counter.ejs

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

+ 4 - 2
layout/search/insight.ejs

@@ -13,9 +13,9 @@
 <script>
     (function ($) {
         $main = $('.ins-search');
+        $container = $('.ins-section-container');
         $main.parent().remove('.ins-search');
         $('body').append($main);
-        $container = $('.ins-section-container');
 
         $(document).on('click focus', '.search-form-input', function () {
             $main.addClass('show');
@@ -26,7 +26,6 @@
             $main.removeClass('show');
         });
 
-
         function section (title) {
             return $('<section>').addClass('ins-section')
                 .append($('<header>').addClass('ins-section-header').text(title));
@@ -190,6 +189,9 @@
         }
 
         $.getJSON('<%- url_for("/content.json")%>', function (json) {
+            if (location.hash.trim() == '#ins-search') {
+                $main.addClass('show');
+            }
             $('.ins-search-input').on('input', function () {
                 var keywords = $(this).val();
                 searchResultToDOM(search(json, keywords));