hugo-theme-relearn/layouts/partials/search.html

31 lines
2 KiB
HTML
Raw Normal View History

<div class="searchbox default-animation">
2021-09-12 08:33:24 +00:00
<label for="search-by"><i class="fas fa-search"></i></label>
<input data-search-input id="search-by" type="search" placeholder="{{ T "Search-placeholder" }}">
<span data-search-clear=""><i class="fas fa-times"></i></span>
</div>
{{- $assetBusting := not .Site.Params.disableAssetsBusting }}
2022-06-12 12:05:01 +00:00
{{- $pageBaseLang := replaceRE "([a-z]+).*" "${1}" .Page.Lang }}
{{- $contentlangs := (union (slice | append .Site.Params.additionalContentLanguage) (slice $pageBaseLang)) }}
2022-06-12 17:24:14 +00:00
{{- $quotedcontentlangs := slice }}
{{- $missingcontentlangs := slice }}
2022-06-12 17:24:14 +00:00
{{- range $contentlangs }}
{{- $file := (printf "js/lunr.%s.min.js" .) }}
{{- if fileExists (printf "/static/%s" $file) }}
{{- $quotedcontentlangs = $quotedcontentlangs | append (printf "'%s'" .) }}
{{- else }}
{{- $missingcontentlangs = $missingcontentlangs | append . }}
{{- end }}
2022-06-12 17:24:14 +00:00
{{- end }}
{{- $contentlangs = $contentlangs | complement $missingcontentlangs }}
2022-06-12 12:05:01 +00:00
<script>
2022-06-12 17:24:14 +00:00
var contentLangs=[{{ delimit $quotedcontentlangs ", " | safeJS }}];
2022-06-12 12:05:01 +00:00
</script>
<script src="{{"js/auto-complete.js" | relURL}}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" defer></script>
<script src="{{"js/lunr.min.js" | relURL}}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" defer></script>
<script src="{{"js/lunr.stemmer.support.min.js" | relURL}}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" defer></script>
<script src="{{"js/lunr.multi.min.js" | relURL}}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" defer></script>
2022-06-12 17:24:14 +00:00
{{- range $contentlangs }}
{{- $file := (printf "js/lunr.%s.min.js" .) }}
<script src="{{ $file | relURL}}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" defer></script>
2022-06-12 17:24:14 +00:00
{{- end }}
<script src="{{ "js/search.js" | relURL }}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" defer></script>