hugo-theme-stack/layouts/page/search.html
Massimo Maggioni 7dff69b6f5 - Added a search switch in config file
- Added the search function with no highlighting
- Modified the search page accordingly
2021-12-08 17:37:17 +01:00

44 lines
1.6 KiB
HTML

{{ define "body-class" }}template-search{{ end }}
{{ define "head" }}
{{- with .OutputFormats.Get "json" -}}
<link rel="preload" href="{{ .Permalink }}" as="fetch" crossorigin="anonymous">
{{- end -}}
{{ end }}
{{ define "main" }}
<form action="{{ .Permalink }}" class="search-form"{{ with .OutputFormats.Get "json" -}} data-json="{{ .Permalink }}"{{- end }}>
<p>
<label>{{ T "search.title" }}</label>
<input name="keyword" placeholder="{{ T `search.placeholder` }}" />
</p>
<button title="{{ T `search.title` }}">
{{ partial "helper/icon" "search" }}
</button>
</form>
<h3 class="search-result--title section-title"></h3>
<div class="search-result--list article-list--compact"></div>
<script>
window.searchResultTitleTemplate = "{{ T `search.resultTitle` }}"
</script>
{{- $searchfunc := "" -}}
{{- $opts := dict "minify" hugo.IsProduction "JSXFactory" "createElement" -}}
{{- if eq .Site.Params.widgets.search.mode "original" -}}
{{- $searchfunc = "ts/search.tsx" -}}
{{- else if eq .Site.Params.widgets.search.mode "nohighlight" -}}
{{- $searchfunc = "ts/search_nohl.tsx" -}}
{{- else if eq .Site.Params.widgets.search.mode "wholeword" -}}
{{- $searchfunc = "ts/search_ww.tsx" -}}
{{- else if eq .Site.Params.widgets.search.mode "highlight" -}}
{{- $searchfunc = "ts/search_hl.tsx" -}}
{{- else -}}
{{ warnf "Searching function not defined" }}
{{- end -}}
{{- $searchScript := resources.Get $searchfunc | js.Build $opts -}}
<script type="text/javascript" src="{{ $searchScript.RelPermalink }}" defer></script>
{{ partialCached "footer/footer" . }}
{{ end }}