diff options
| author | Serghei Iakovlev <egrep@protonmail.ch> | 2022-07-06 01:47:49 +0200 |
|---|---|---|
| committer | Serghei Iakovlev <egrep@protonmail.ch> | 2022-07-06 01:48:26 +0200 |
| commit | c7ed98af94b9e59ec3233bae562ae3741c6cd906 (patch) | |
| tree | 4c2f4815bfb40a866f4df3f91bcaab271e526cee | |
| parent | 674415135175f22378388f13c6012f03587ee20d (diff) | |
| download | gohugo-theme-ed-c7ed98af94b9e59ec3233bae562ae3741c6cd906.tar.gz | |
Move lunr.js to search form
| -rw-r--r-- | layouts/partials/scripts.html | 9 | ||||
| -rw-r--r-- | layouts/shortcodes/form-search.html | 19 |
2 files changed, 20 insertions, 8 deletions
diff --git a/layouts/partials/scripts.html b/layouts/partials/scripts.html index e931587..137cae2 100644 --- a/layouts/partials/scripts.html +++ b/layouts/partials/scripts.html @@ -1,17 +1,10 @@ {{- $vendors := slice -}} -{{- $vendorNames := slice "jquery.js" "lunr.js" -}} +{{- $vendorNames := slice "jquery.js" -}} {{- range $vendorNames -}} {{ $vendors = $vendors | append (resources.Get (printf "js/vendor/%s" .) ) }} {{- end -}} -{{- $vendors = $vendors | append (resources.Get "js/vendor/lunr.stemmer.support.js" ) -}} -{{- $lunrLangs := slice "de" "es" "fr" "it" "pt" "ru" -}} -{{- range $lunrLangs -}} - {{ $vendors = $vendors | append (resources.Get (printf "js/vendor/lunr.%s.js" .) ) }} -{{- end -}} -{{- $vendors = $vendors | append (resources.Get "js/vendor/lunr.multi.js" ) -}} - {{- $vendors = $vendors | resources.Concat "js/vendor-bundle.js" -}} {{- if or (eq (getenv "HUGO_ENV") "production") (eq site.Params.env "production") }} {{- $vendors = $vendors | minify -}} diff --git a/layouts/shortcodes/form-search.html b/layouts/shortcodes/form-search.html index 614ec35..e9a9175 100644 --- a/layouts/shortcodes/form-search.html +++ b/layouts/shortcodes/form-search.html @@ -19,6 +19,25 @@ {{- partial "search-results" . -}} +{{- $vendors := slice (resources.Get "js/vendor/lunr.js") -}} +{{- $vendors = $vendors | append (resources.Get "js/vendor/lunr.multi.js" ) -}} +{{- $vendors = $vendors | append (resources.Get "js/vendor/lunr.stemmer.support.js" ) -}} +{{- $lunrLangs := slice "de" "es" "fr" "it" "pt" "ru" -}} +{{- range $lunrLangs -}} + {{ $vendors = $vendors | append (resources.Get (printf "js/vendor/lunr.%s.js" .) ) }} +{{- end -}} + +{{- $vendors = $vendors | resources.Concat "js/lunr-bundle.js" -}} +{{- if or (eq (getenv "HUGO_ENV") "production") (eq site.Params.env "production") }} + {{- $vendors = $vendors | minify -}} +{{- end -}} +{{- if not site.Params.assets.disable_fingerprinting -}} + {{- $vendors = $vendors | fingerprint -}} + <script src="{{ $vendors.RelPermalink }}" integrity="{{ $vendors.Data.Integrity }}"></script> +{{- else -}} + <script src="{{ $vendors.RelPermalink }}"></script> +{{- end -}} + {{- $search := resources.Get "js/search.js" -}} {{- if or (eq (getenv "HUGO_ENV") "production") (eq site.Params.env "production") }} {{- $search = $search | minify -}} |
