Search: Use relative URLs within generated configuration and data files

Always use relative URLs when generating the configuration and data file
for the search bar.
This fixes issues with deployments that run under a sub-path, e.g.
https://example.com/path.
This commit is contained in:
Noxx 2025-02-04 14:29:46 +01:00 committed by Markus Richter
parent 5888203d0d
commit 3f7aab769e
No known key found for this signature in database
GPG Key ID: E3BEBF30D61B6E72
2 changed files with 2 additions and 2 deletions

View File

@ -1,7 +1,7 @@
{{- $searchDataFile := printf "search/%s.data.json" .Language.Lang -}}
{{- $searchData := resources.Get "search/data.json" | resources.ExecuteAsTemplate $searchDataFile . | resources.Minify -}}
{
"dataFile": {{ $searchData.RelPermalink | jsonify }},
"dataFile": {{ printf ".%s" $searchData.RelPermalink | jsonify }},
"indexConfig": {{ .Site.Params.geekdocSearchConfig | jsonify }},
"showParent": {{ if .Site.Params.geekdocSearchShowParent }}true{{ else }}false{{ end }},
"showDescription": {{ if .Site.Params.geekdocSearchshowDescription }}true{{ else }}false{{ end }}

View File

@ -3,7 +3,7 @@
{{ if ne $index 0 }},{{ end }}
{
"id": {{ $index }},
"href": "{{ $page.RelPermalink }}",
"href": ".{{ $page.RelPermalink }}",
"title": {{ (partial "utils/title" $page) | jsonify }},
"parent": {{ with $page.Parent }}{{ (partial "utils/title" .) | jsonify }}{{ else }}""{{ end }},
"content": {{ $page.Plain | jsonify }},