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
|
// 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) -}}
|
{{ $len := (len $list) -}}
|
||||||
|
|
||||||
{{ range $index, $element := $list -}}
|
{{ range $index, $element := $list -}}
|
||||||
|
|
|
@ -83,6 +83,8 @@ lastMod = false
|
||||||
clipBoard = true
|
clipBoard = true
|
||||||
instantPage = true
|
instantPage = true
|
||||||
flexSearch = true
|
flexSearch = true
|
||||||
|
searchSectionsShow = []
|
||||||
|
searchSectionsIndex = []
|
||||||
darkMode = true
|
darkMode = true
|
||||||
bootStrapJs = true
|
bootStrapJs = true
|
||||||
breadCrumb = false
|
breadCrumb = false
|
||||||
|
|
|
@ -34,9 +34,14 @@
|
||||||
{{ $slice = $slice | append $instantPage -}}
|
{{ $slice = $slice | append $instantPage -}}
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
|
|
||||||
{{ if .Site.Params.options.flexSearch -}}
|
{{ $showFlexSearch := .Site.Params.options.flexSearch }}
|
||||||
|
|
||||||
|
{{ if $showFlexSearch -}}
|
||||||
{{ $flexSearch := resources.Get "js/vendor/flexsearch/dist/flexsearch.bundle.js" -}}
|
{{ $flexSearch := resources.Get "js/vendor/flexsearch/dist/flexsearch.bundle.js" -}}
|
||||||
{{ $slice = $slice | append $flexSearch -}}
|
{{ $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 -}}
|
{{ end -}}
|
||||||
|
|
||||||
{{ if .Site.Params.options.darkMode -}}
|
{{ if .Site.Params.options.darkMode -}}
|
||||||
|
@ -83,7 +88,7 @@
|
||||||
{{ with .Params.mermaid -}}
|
{{ with .Params.mermaid -}}
|
||||||
<script src="{{ $mermaid.RelPermalink }}" defer></script>
|
<script src="{{ $mermaid.RelPermalink }}" defer></script>
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
{{ if .Site.Params.options.flexSearch -}}
|
{{ if $showFlexSearch -}}
|
||||||
<script src="{{ $index.RelPermalink }}" defer></script>
|
<script src="{{ $index.RelPermalink }}" defer></script>
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
{{ else -}}
|
{{ else -}}
|
||||||
|
@ -108,7 +113,7 @@
|
||||||
{{ with .Params.mermaid -}}
|
{{ with .Params.mermaid -}}
|
||||||
<script src="{{ $mermaid.RelPermalink }}" integrity="{{ $mermaid.Data.Integrity }}" crossorigin="anonymous" defer></script>
|
<script src="{{ $mermaid.RelPermalink }}" integrity="{{ $mermaid.Data.Integrity }}" crossorigin="anonymous" defer></script>
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
{{ if .Site.Params.options.flexSearch -}}
|
{{ if $showFlexSearch -}}
|
||||||
<script src="{{ $index.Permalink }}" integrity="{{ $index.Data.Integrity }}" crossorigin="anonymous" defer></script>
|
<script src="{{ $index.Permalink }}" integrity="{{ $index.Data.Integrity }}" crossorigin="anonymous" defer></script>
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
{{ end -}}
|
{{ end -}}
|
|
@ -77,7 +77,14 @@
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
</ul>
|
</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">
|
<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">
|
<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">
|
<input id="search" class="form-control is-search" type="search" placeholder="Search docs..." aria-label="Search docs..." autocomplete="off">
|
||||||
|
|
Loading…
Reference in New Issue