diff options
author | Jimmy Cai <jimmehcai@gmail.com> | 2021-01-01 15:12:23 +0300 |
---|---|---|
committer | Jimmy Cai <jimmehcai@gmail.com> | 2021-01-01 15:12:23 +0300 |
commit | 5ac2552e7c5f8cff0bf0f34c9cbc42bf8d344f45 (patch) | |
tree | 187c696f38a7fc76910b289dea2d5b1bed094884 /layouts | |
parent | ae477ab224489c9a5ff56705da5f84296ca82bb1 (diff) |
fix(widget/search): remove hardcoded form action
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/partials/widget/search.html | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/layouts/partials/widget/search.html b/layouts/partials/widget/search.html index 2275eb9..833f740 100644 --- a/layouts/partials/widget/search.html +++ b/layouts/partials/widget/search.html @@ -1,10 +1,16 @@ -<form action="/search" 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"> - {{ partial "helper/icon" "search" }} - </button> - </p> -</form>
\ No newline at end of file +{{- $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="{{ T `search.title` }}"> + {{ partial "helper/icon" "search" }} + </button> + </p> + </form> +{{- else -}} + {{- warnf "Search page not found. Create a page with layout: search." -}} +{{- end -}}
\ No newline at end of file |