diff --git a/assets/js/index.js b/assets/js/index.js index dbaaa28..2f47890 100644 --- a/assets/js/index.js +++ b/assets/js/index.js @@ -95,7 +95,7 @@ Source: // https://discourse.gohugo.io/t/range-length-or-last-element/3803/2 {{ $list := slice }} - {{- if eq (len .Site.Params.options.searchSectionsIndex) 0 }} + {{- if or (not (isset .Site.Params.options "searchsectionsindex")) (eq (len .Site.Params.options.searchSectionsIndex) 0) }} {{- $list = (where .Site.Pages "Section" "docs") }} {{- else }} {{- $list = (where .Site.Pages "Type" "in" .Site.Params.options.searchSectionsIndex) }} diff --git a/layouts/partials/footer/script-footer.html b/layouts/partials/footer/script-footer.html index 8cfe03e..769494a 100644 --- a/layouts/partials/footer/script-footer.html +++ b/layouts/partials/footer/script-footer.html @@ -34,13 +34,16 @@ {{ $slice = $slice | append $instantPage -}} {{ end -}} -{{ if .Site.Params.options.flexSearch -}} +{{ $showFlexSearch := .Site.Params.options.flexSearch }} + +{{ if $showFlexSearch -}} {{ $flexSearch := resources.Get "js/vendor/flexsearch/dist/flexsearch.bundle.js" -}} {{ $slice = $slice | append $flexSearch -}} + {{ if (isset .Site.Params.options "searchsectionsshow") -}} + {{ $showFlexSearch = or (eq (len .Site.Params.options.searchSectionsShow) 0) (in .Site.Params.options.searchSectionsShow .Section) -}} + {{ end -}} {{ end -}} -{{ $includeFlexSearch := and .Site.Params.options.flexSearch (or (eq (len .Site.Params.options.searchSectionsShow) 0) (in .Site.Params.options.searchSectionsShow .Section)) }} - {{ if .Site.Params.options.darkMode -}} {{ $darkMode := resources.Get "js/darkmode.js" -}} {{ $darkMode := $darkMode | js.Build -}} @@ -79,7 +82,7 @@ {{ with .Params.mermaid -}} {{ end -}} - {{ if $includeFlexSearch -}} + {{ if $showFlexSearch -}} {{ end -}} {{ else -}} @@ -104,7 +107,7 @@ {{ with .Params.mermaid -}} {{ end -}} - {{ if $includeFlexSearch -}} + {{ if $showFlexSearch -}} {{ end -}} {{ end -}} diff --git a/layouts/partials/header/header.html b/layouts/partials/header/header.html index 5dfae5b..8b4e4ca 100644 --- a/layouts/partials/header/header.html +++ b/layouts/partials/header/header.html @@ -77,7 +77,14 @@ {{ end -}} - {{ if and .Site.Params.options.flexSearch (or (eq (len .Site.Params.options.searchSectionsShow) 0) (in .Site.Params.options.searchSectionsShow .Section)) -}} + {{- $showFlexSearch := .Site.Params.options.flexSearch }} + {{- if $showFlexSearch }} + {{- if (isset .Site.Params.options "searchsectionsshow") }} + {{- $showFlexSearch = or (eq (len .Site.Params.options.searchSectionsShow) 0) (in .Site.Params.options.searchSectionsShow .Section) }} + {{- end }} + {{- end }} + + {{ if $showFlexSearch -}}