diff options
author | James Elliott <james-d-elliott@users.noreply.github.com> | 2022-06-25 05:20:57 +0300 |
---|---|---|
committer | James Elliott <james-d-elliott@users.noreply.github.com> | 2022-06-25 05:20:57 +0300 |
commit | fa01f4ab56541a5acc954f04cc48c67ffa2772ee (patch) | |
tree | 33d52b245a412ebb827231c2cc248d87cbee1e1a /layouts | |
parent | 00e4a7886e830b26838b5a33793d5e75086e4ce8 (diff) |
fix: avoid error if unset
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/partials/footer/script-footer.html | 13 | ||||
-rw-r--r-- | layouts/partials/header/header.html | 9 |
2 files changed, 16 insertions, 6 deletions
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 -}} <script src="{{ $mermaid.RelPermalink }}" defer></script> {{ end -}} - {{ if $includeFlexSearch -}} + {{ if $showFlexSearch -}} <script src="{{ $index.RelPermalink }}" defer></script> {{ end -}} {{ else -}} @@ -104,7 +107,7 @@ {{ with .Params.mermaid -}} <script src="{{ $mermaid.RelPermalink }}" integrity="{{ $mermaid.Data.Integrity }}" crossorigin="anonymous" defer></script> {{ end -}} - {{ if $includeFlexSearch -}} + {{ if $showFlexSearch -}} <script src="{{ $index.Permalink }}" integrity="{{ $index.Data.Integrity }}" crossorigin="anonymous" defer></script> {{ 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 -}} </ul> - {{ 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 -}} <hr class="text-black-50 my-4 d-lg-none"> <form class="doks-search position-relative flex-grow-1 ms-lg-auto me-lg-2"> <input id="search" class="form-control is-search" type="search" placeholder="Search docs..." aria-label="Search docs..." autocomplete="off"> |