feat: use .RelPermalink for search JSON (#859)

Avoids CORS problem when the user inputs `baseurl` incorrectly.
This commit is contained in:
Jimmy Cai 2023-08-15 11:40:43 +02:00 committed by GitHub
parent f7e442cabb
commit 1668ebc3e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,11 +1,11 @@
{{ define "body-class" }}template-search{{ end }} {{ define "body-class" }}template-search{{ end }}
{{ define "head" }} {{ define "head" }}
{{- with .OutputFormats.Get "json" -}} {{- with .OutputFormats.Get "json" -}}
<link rel="preload" href="{{ .Permalink }}" as="fetch" crossorigin="anonymous"> <link rel="preload" href="{{ .RelPermalink }}" as="fetch" crossorigin="anonymous">
{{- end -}} {{- end -}}
{{ end }} {{ end }}
{{ define "main" }} {{ define "main" }}
<form action="{{ .Permalink }}" class="search-form"{{ with .OutputFormats.Get "json" -}} data-json="{{ .Permalink }}"{{- end }}> <form action="{{ .RelPermalink }}" class="search-form"{{ with .OutputFormats.Get "json" -}} data-json="{{ .RelPermalink }}"{{- end }}>
<p> <p>
<label>{{ T "search.title" }}</label> <label>{{ T "search.title" }}</label>
<input name="keyword" placeholder="{{ T `search.placeholder` }}" /> <input name="keyword" placeholder="{{ T `search.placeholder` }}" />