search: make creation of index faster #685 #888

This commit is contained in:
Sören Weber 2024-08-30 00:28:52 +02:00
parent d4cbccdde0
commit 20136aa4e7
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D

View file

@ -9,9 +9,11 @@
{{- end }}
{{- if not .Site.Params.disableSearchIndex }}
{{- $url := path.Join .Site.LanguagePrefix (trim (or .Site.Params.searchIndexURL "searchindex.js") "/") }}
{{- $templateres := resources.Get "_relearn_searchindex.js" }}
{{- $resultres := $templateres | resources.ExecuteAsTemplate $url .Site.Home }}
{{- /* the following code causes Hugo to generate our file - although it is in comments */}}<!-- {{ $resultres.RelPermalink }} -->
{{- if .IsHome }}
{{- $templateres := resources.Get "_relearn_searchindex.js" }}
{{- $resultres := $templateres | resources.ExecuteAsTemplate $url .Site.Home }}
{{- /* the following code causes Hugo to generate our file - although it is in comments */}}<!-- {{ $resultres.RelPermalink }} -->
{{- end }}
<script>
window.index_js_url={{ (printf "%s%s" $url $assetBusting) | relLangURL }};
</script>