fix(widget/search): remove hardcoded form action

This commit is contained in:
Jimmy Cai 2021-01-01 13:12:23 +01:00
parent ae477ab224
commit 5ac2552e7c
No known key found for this signature in database
GPG Key ID: 3EA408E527F37B18

View File

@ -1,10 +1,16 @@
<form action="/search" class="search-form widget" {{ with .OutputFormats.Get "json" -}}data-json="{{ .Permalink }}" {{- end }}>
{{- $query := first 1 (where .Site.Pages "Layout" "==" "search") -}}
{{- if $query -}}
{{- $searchPage := index $query 0 -}}
<form action="{{ $searchPage.RelPermalink }}" class="search-form widget" {{ with .OutputFormats.Get "json" -}}data-json="{{ .Permalink }}" {{- end }}>
<p>
<label>{{ T "search.title" }}</label>
<input name="keyword" required placeholder="{{ T `search.placeholder` }}" />
<button title="Search">
<button title="{{ T `search.title` }}">
{{ partial "helper/icon" "search" }}
</button>
</p>
</form>
{{- else -}}
{{- warnf "Search page not found. Create a page with layout: search." -}}
{{- end -}}