diff --git a/assets/js/custom.js b/assets/js/custom.js index 503774b..cb653bb 100644 --- a/assets/js/custom.js +++ b/assets/js/custom.js @@ -1,40 +1,33 @@ -console.log('Custom script loaded'); - -function smoothScroll(e) { - const href = this.getAttribute('href'); - console.log('Clicked link:', href); - - if (href.startsWith('/#')) { +window.addEventListener('load', function() { + console.log('Custom script loaded'); + + function smoothScroll(e) { + const href = this.getAttribute('href'); + console.log('Clicked link:', href); + + if (href.startsWith('/#')) { e.preventDefault(); console.log('Preventing default behavior for:', href); - + const targetId = href.replace('/#', ''); const targetElement = document.getElementById(targetId); - + if (targetElement) { - console.log('Scrolling to:', targetId); - targetElement.scrollIntoView({ - behavior: 'smooth' - }); + console.log('Scrolling to:', targetId); + targetElement.scrollIntoView({ + behavior: 'smooth' + }); } else { - console.log('Target element not found:', targetId); + console.log('Target element not found:', targetId); } + } } -} - -function attachSmoothScroll() { - console.log('Attaching smooth scroll'); + const menuLinks = document.querySelectorAll('a[href^="/#"]'); console.log('Found menu links:', menuLinks.length); - + menuLinks.forEach(link => { - console.log('Adding listener to:', link.href); - link.addEventListener('click', smoothScroll); + console.log('Adding listener to:', link.href); + link.addEventListener('click', smoothScroll); }); -} - -// Try to attach immediately -attachSmoothScroll(); - -// Also attach when the DOM is fully loaded -document.addEventListener('DOMContentLoaded', attachSmoothScroll); \ No newline at end of file + }); \ No newline at end of file diff --git a/config/_default/params.yaml b/config/_default/params.yaml index 33c6c5b..be8b448 100644 --- a/config/_default/params.yaml +++ b/config/_default/params.yaml @@ -35,7 +35,7 @@ header: show_search: true show_theme_chooser: true logo: - text: "Your Name" + text: "Chris Larkin" # Site footer footer: @@ -58,3 +58,7 @@ features: enable: false privacy_pack: enable: false + +# Append custom JavaScript +plugins_js: + - custom \ No newline at end of file diff --git a/layouts/partials/hooks/head-end.html b/layouts/partials/hooks/head-end.html index 98bffe3..c30ba92 100644 --- a/layouts/partials/hooks/head-end.html +++ b/layouts/partials/hooks/head-end.html @@ -1,2 +1 @@ -{{ $custom_js := resources.Get "js/custom.js" | js.Build "custom.js" }} - \ No newline at end of file + diff --git a/static/js/smooth-scroll.js b/static/js/smooth-scroll.js deleted file mode 100644 index f43c6fd..0000000 --- a/static/js/smooth-scroll.js +++ /dev/null @@ -1,35 +0,0 @@ -console.log('Smooth scroll script loaded and running'); - -document.addEventListener('DOMContentLoaded', function() { - console.log('DOM fully loaded'); - const menuLinks = document.querySelectorAll('nav a[href^="#"]'); - console.log('Found menu links:', menuLinks.length); - - menuLinks.forEach(link => { - link.addEventListener('click', function(e) { - const href = this.getAttribute('href'); - console.log('Clicked link:', href); - - // Only apply smooth scroll to Research, Posts, and Contact - if (href !== '#papers' && href !== '#news' && href !== '#contact') { - console.log('Skipping smooth scroll for:', href); - return; - } - - e.preventDefault(); - console.log('Preventing default behavior for:', href); - - const targetId = href.replace('#', ''); - const targetElement = document.getElementById(targetId); - - if (targetElement) { - console.log('Scrolling to:', targetId); - targetElement.scrollIntoView({ - behavior: 'smooth' - }); - } else { - console.log('Target element not found:', targetId); - } - }); - }); -}); \ No newline at end of file