diff --git a/assets/js/menu.js b/assets/js/menu.js new file mode 100644 index 00000000..ec43bfcd --- /dev/null +++ b/assets/js/menu.js @@ -0,0 +1,6 @@ +/* + Closes the hamburger menu when a link is clicked. +*/ +function close_menu() { + document.getElementById('menu-controller').checked=false +} \ No newline at end of file diff --git a/exampleSite/config/_default/params.toml b/exampleSite/config/_default/params.toml index 2b3fa153..caa71c21 100644 --- a/exampleSite/config/_default/params.toml +++ b/exampleSite/config/_default/params.toml @@ -17,7 +17,7 @@ enableImageLazyLoading = true fingerprintAlgorithm = "sha256" [header] - layout = "basic" # valid options: basic, hamburger, hybrid, custom + layout = "hybrid" # valid options: basic, hamburger, hybrid, custom # logo = "img/logo.jpg" # logoDark = "img/dark-logo.jpg" showTitle = true diff --git a/layouts/partials/head.html b/layouts/partials/head.html index cbae8736..add457c7 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -47,6 +47,10 @@ {{ $jsCode := resources.Get "js/code.js" }} {{ $assets.Add "js" (slice $jsCode) }} {{ end }} + {{ if or (eq .Site.Params.header.layout "hamburger") (eq .Site.Params.header.layout "hybrid") }} + {{ $jsMenu := resources.Get "js/menu.js" }} + {{ $assets.Add "js" (slice $jsMenu) }} + {{ end }} {{ if eq (site.Language.LanguageDirection | default "ltr") "rtl" }} {{ $jsRTL := resources.Get "js/rtl.js" }} {{ $assets.Add "js" (slice $jsRTL) }} diff --git a/layouts/partials/header/hamburger.html b/layouts/partials/header/hamburger.html index 6270bd33..fbd5e12c 100644 --- a/layouts/partials/header/hamburger.html +++ b/layouts/partials/header/hamburger.html @@ -93,6 +93,7 @@ {{ with .Params.icon }} {{ with .Params.icon }}