Parcourir la source

:sparkles: Fix JS hash scrolling

George Cushen il y a 9 ans
Parent
commit
4130199888
2 fichiers modifiés avec 5 ajouts et 2 suppressions
  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" . }}
 <div class="container">
 
+    <!-- Flag for jQuery -->
+    <span id="homepage" style="display: none"></span>
+
+
     <!-- Biography Section -->
     {{ range $index, $page := where .Site.Pages "Section" "=" "home" }}
     {{ 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){
 
     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
       event.preventDefault();