diff --git a/static/js/page.js b/static/js/page.js new file mode 100644 index 0000000..d595a82 --- /dev/null +++ b/static/js/page.js @@ -0,0 +1,12 @@ +document.addEventListener('DOMContentLoaded', function() { + const mainNavHashLinks = document.querySelectorAll( + 'rh-navigation-primary-item[href^="#"], rh-navigation-primary-item > a[href^="#"]' + ); + + // Close dropdowns after clicking an in-page link on mobile viewports + for (let hashLink of mainNavHashLinks) { + hashLink.addEventListener('click', function() { + hashLink.closest('rh-navigation-primary').close(); + }); + } +}); diff --git a/templates/index.html b/templates/index.html index 1f1caa0..e1e6e00 100644 --- a/templates/index.html +++ b/templates/index.html @@ -116,6 +116,7 @@

{{ elem.heading }}

{% include "partials/_footer.html" %} +