From b532c69bd769353490e412e22d790e484aeb91dc Mon Sep 17 00:00:00 2001 From: James Elliott Date: Sat, 25 Jun 2022 13:36:32 +1000 Subject: [PATCH] feat: add all method --- assets/js/index.js | 8 ++++++-- layouts/partials/footer/script-footer.html | 2 +- layouts/partials/header/header.html | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/assets/js/index.js b/assets/js/index.js index 2f47890..0c2de5d 100644 --- a/assets/js/index.js +++ b/assets/js/index.js @@ -95,11 +95,15 @@ Source: // https://discourse.gohugo.io/t/range-length-or-last-element/3803/2 {{ $list := slice }} - {{- if or (not (isset .Site.Params.options "searchsectionsindex")) (eq (len .Site.Params.options.searchSectionsIndex) 0) }} - {{- $list = (where .Site.Pages "Section" "docs") }} + {{- if and (isset .Site.Params.options "searchsectionsindex") (not (eq (len .Site.Params.options.searchSectionsIndex) 0)) }} + {{- if eq .Site.Params.options.searchSectionsIndex "ALL" }} + {{- $list = .Site.Pages }} {{- else }} {{- $list = (where .Site.Pages "Type" "in" .Site.Params.options.searchSectionsIndex) }} {{- end }} + {{- else }} + {{- $list = (where .Site.Pages "Section" "docs") }} + {{- end }} {{ $len := (len $list) -}} diff --git a/layouts/partials/footer/script-footer.html b/layouts/partials/footer/script-footer.html index 769494a..1a571d1 100644 --- a/layouts/partials/footer/script-footer.html +++ b/layouts/partials/footer/script-footer.html @@ -39,7 +39,7 @@ {{ if $showFlexSearch -}} {{ $flexSearch := resources.Get "js/vendor/flexsearch/dist/flexsearch.bundle.js" -}} {{ $slice = $slice | append $flexSearch -}} - {{ if (isset .Site.Params.options "searchsectionsshow") -}} + {{ if and (isset .Site.Params.options "searchsectionsshow") (not (eq .Site.Params.options.searchSectionsShow "ALL")) -}} {{ $showFlexSearch = or (eq (len .Site.Params.options.searchSectionsShow) 0) (in .Site.Params.options.searchSectionsShow .Section) -}} {{ end -}} {{ end -}} diff --git a/layouts/partials/header/header.html b/layouts/partials/header/header.html index 8b4e4ca..77c24de 100644 --- a/layouts/partials/header/header.html +++ b/layouts/partials/header/header.html @@ -79,7 +79,7 @@ {{- $showFlexSearch := .Site.Params.options.flexSearch }} {{- if $showFlexSearch }} - {{- if (isset .Site.Params.options "searchsectionsshow") }} + {{- if and (isset .Site.Params.options "searchsectionsshow") (not (eq .Site.Params.options.searchSectionsShow "ALL")) }} {{- $showFlexSearch = or (eq (len .Site.Params.options.searchSectionsShow) 0) (in .Site.Params.options.searchSectionsShow .Section) }} {{- end }} {{- end }}