소스 검색

:sparkles: Fix JS hash scrolling

George Cushen 9 년 전
부모
커밋
4130199888
2개의 변경된 파일5개의 추가작업 그리고 2개의 파일을 삭제
  1. 4 0
      layouts/index.html
  2. 1 2
      static/js/hugo-academic.js

+ 4 - 0
layouts/index.html

@@ -2,6 +2,10 @@
 {{ partial "navbar.html" . }}
 {{ partial "navbar.html" . }}
 <div class="container">
 <div class="container">
 
 
+    <!-- Flag for jQuery -->
+    <span id="homepage" style="display: none"></span>
+
+
     <!-- Biography Section -->
     <!-- Biography Section -->
     {{ range $index, $page := where .Site.Pages "Section" "=" "home" }}
     {{ range $index, $page := where .Site.Pages "Section" "=" "home" }}
     {{ if eq .Title "about" }}
     {{ if eq .Title "about" }}

+ 1 - 2
static/js/hugo-academic.js

@@ -12,9 +12,8 @@
   $("#navbar-main li.nav-item a").on('click', function(event){
   $("#navbar-main li.nav-item a").on('click', function(event){
 
 
     var hash = this.hash;
     var hash = this.hash;
-    var url = $(this).attr('href');
 
 
-    if( hash && $(hash).length && (url.split('#')[0] == window.location.pathname)) {
+    if( hash && $(hash).length && ($("#homepage").length > 0)) {
       // Prevent default click behavior
       // Prevent default click behavior
       event.preventDefault();
       event.preventDefault();