Merge pull request #799 from james-d-elliott/feat-search-sections
feat(search): allow complete section customization
This commit is contained in:
commit
58d77b2434
|
@ -94,7 +94,20 @@ Source:
|
|||
|
||||
// https://discourse.gohugo.io/t/range-length-or-last-element/3803/2
|
||||
|
||||
{{ $list := (where .Site.Pages "Section" "docs") -}}
|
||||
{{ $list := slice }}
|
||||
{{- 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) }}
|
||||
{{- if (in .Site.Params.options.searchSectionsIndex "HomePage") }}
|
||||
{{ $list = $list | append .Site.Home }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- $list = (where .Site.Pages "Section" "docs") }}
|
||||
{{- end }}
|
||||
|
||||
{{ $len := (len $list) -}}
|
||||
|
||||
{{ range $index, $element := $list -}}
|
||||
|
|
|
@ -83,6 +83,8 @@ lastMod = false
|
|||
clipBoard = true
|
||||
instantPage = true
|
||||
flexSearch = true
|
||||
searchSectionsShow = []
|
||||
searchSectionsIndex = []
|
||||
darkMode = true
|
||||
bootStrapJs = true
|
||||
breadCrumb = false
|
||||
|
|
|
@ -34,9 +34,14 @@
|
|||
{{ $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 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) (and .IsHome (in .Site.Params.options.searchSectionsShow "HomePage")) -}}
|
||||
{{ end -}}
|
||||
{{ end -}}
|
||||
|
||||
{{ if .Site.Params.options.darkMode -}}
|
||||
|
@ -83,7 +88,7 @@
|
|||
{{ with .Params.mermaid -}}
|
||||
<script src="{{ $mermaid.RelPermalink }}" defer></script>
|
||||
{{ end -}}
|
||||
{{ if .Site.Params.options.flexSearch -}}
|
||||
{{ if $showFlexSearch -}}
|
||||
<script src="{{ $index.RelPermalink }}" defer></script>
|
||||
{{ end -}}
|
||||
{{ else -}}
|
||||
|
@ -108,7 +113,7 @@
|
|||
{{ with .Params.mermaid -}}
|
||||
<script src="{{ $mermaid.RelPermalink }}" integrity="{{ $mermaid.Data.Integrity }}" crossorigin="anonymous" defer></script>
|
||||
{{ end -}}
|
||||
{{ if .Site.Params.options.flexSearch -}}
|
||||
{{ if $showFlexSearch -}}
|
||||
<script src="{{ $index.Permalink }}" integrity="{{ $index.Data.Integrity }}" crossorigin="anonymous" defer></script>
|
||||
{{ end -}}
|
||||
{{ end -}}
|
|
@ -77,7 +77,14 @@
|
|||
{{ end -}}
|
||||
</ul>
|
||||
|
||||
{{ if .Site.Params.options.flexSearch -}}
|
||||
{{- $showFlexSearch := .Site.Params.options.flexSearch }}
|
||||
{{- if $showFlexSearch }}
|
||||
{{- 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) (and .IsHome (in .Site.Params.options.searchSectionsShow "HomePage")) }}
|
||||
{{- 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">
|
||||
|
|
Loading…
Reference in New Issue