From a785bb0dbf6597e24689cd010f18244046ffae55 Mon Sep 17 00:00:00 2001 From: Wen Junhua Date: Sun, 12 Nov 2023 19:45:05 +0800 Subject: [PATCH 1/3] fix: close menu button on click --- layouts/partials/header/hamburger.html | 1 + 1 file changed, 1 insertion(+) diff --git a/layouts/partials/header/hamburger.html b/layouts/partials/header/hamburger.html index 1982d81b..21aaca32 100644 --- a/layouts/partials/header/hamburger.html +++ b/layouts/partials/header/hamburger.html @@ -93,6 +93,7 @@ {{ with .Params.icon }} Date: Sat, 25 Nov 2023 12:46:52 +0800 Subject: [PATCH 2/3] fix; move function to another file --- assets/js/menu.js | 6 ++++++ exampleSite/config/_default/params.toml | 2 +- layouts/partials/head.html | 4 ++++ layouts/partials/header/hamburger.html | 2 +- 4 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 assets/js/menu.js 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 d828f120..af12c3de 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 = "hamburger" # 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..6a0c35fe 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 eq .Site.Params.header.layout "hamburger" }} + {{ $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 21aaca32..23cb4723 100644 --- a/layouts/partials/header/hamburger.html +++ b/layouts/partials/header/hamburger.html @@ -93,7 +93,7 @@ {{ with .Params.icon }} Date: Sun, 26 Nov 2023 23:15:17 +0800 Subject: [PATCH 3/3] fix: update hybrid menu as well --- exampleSite/config/_default/params.toml | 2 +- layouts/partials/head.html | 2 +- layouts/partials/header/hybrid.html | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/exampleSite/config/_default/params.toml b/exampleSite/config/_default/params.toml index af12c3de..9e2bcb74 100644 --- a/exampleSite/config/_default/params.toml +++ b/exampleSite/config/_default/params.toml @@ -17,7 +17,7 @@ enableImageLazyLoading = true fingerprintAlgorithm = "sha256" [header] - layout = "hamburger" # 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 6a0c35fe..add457c7 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -47,7 +47,7 @@ {{ $jsCode := resources.Get "js/code.js" }} {{ $assets.Add "js" (slice $jsCode) }} {{ end }} - {{ if eq .Site.Params.header.layout "hamburger" }} + {{ 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 }} diff --git a/layouts/partials/header/hybrid.html b/layouts/partials/header/hybrid.html index b07bb523..34440e34 100644 --- a/layouts/partials/header/hybrid.html +++ b/layouts/partials/header/hybrid.html @@ -93,6 +93,7 @@ {{ with .Params.icon }}