Skip to content

Commit

Permalink
fix: do not call resources.Get on cdn urls
Browse files Browse the repository at this point in the history
Close #1313
  • Loading branch information
HEIGE-PCloud committed Jul 6, 2024
1 parent 9b8606b commit a36cb5b
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions layouts/partials/assets.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,20 @@

{{- /* Search */ -}}
{{- if .Site.Params.search | and .Site.Params.search.enable -}}
{{- $source := $cdn.autocompleteJS | default "lib/autocomplete/autocomplete.min.js" -}}
{{- $js := resources.Get $source -}}
{{- $config = dict "autocomplete.min.js" $js.RelPermalink | merge $config}}
{{- $src := cond (eq $cdn.autocompleteJS nil) (resources.Get "lib/autocomplete/autocomplete.min.js").RelPermalink $cdn.autocompleteJS -}}
{{- $config = dict "autocomplete.min.js" $src | merge $config}}
{{- $search := .Site.Params.search -}}
{{- $config = dict "maxResultLength" $search.maxResultLength "snippetLength" $search.snippetLength "highlightTag" $search.highlightTag "noResultsFound" (T "noResultsFound") | dict "search" | merge $config -}}
{{- if eq $search.type "algolia" -}}
{{- $source := $cdn.algoliasearchJS | default "lib/algoliasearch/algoliasearch-lite.umd.min.js" -}}
{{- $js := resources.Get $source -}}
{{- $config = dict "algoliasearch.min.js" $js.RelPermalink | merge $config}}
{{- $src := cond (eq $cdn.algoliasearchJS nil) (resources.Get "lib/algoliasearch/algoliasearch-lite.umd.min.js").RelPermalink $cdn.algoliasearchJS -}}
{{- $config = dict "algoliasearch.min.js" $src | merge $config}}
{{- $config = dict "type" "algolia" "algoliaIndex" $search.algolia.index "algoliaAppID" $search.algolia.appID "algoliaSearchKey" $search.algolia.searchKey | dict "search" | merge $config -}}
{{- else -}}
{{- with .Site.Home.OutputFormats.Get "json" -}}
{{- $config = dict "type" "fuse" "fuseIndexURL" .RelPermalink | dict "search" | merge $config -}}
{{- end -}}
{{- $source := $cdn.fuseJS | default "lib/fuse/fuse.min.js" -}}
{{- $js := resources.Get $source -}}
{{- $config = dict "fuse.min.js" $js.RelPermalink | merge $config}}
{{- $src := cond (eq $cdn.fuseJS nil) (resources.Get "lib/fuse/fuse.min.js").RelPermalink $cdn.fuseJS -}}
{{- $config = dict "fuse.min.js" $src | merge $config}}
{{- $config = dict "isCaseSensitive" $search.fuse.isCaseSensitive "minMatchCharLength" $search.fuse.minMatchCharLength "findAllMatches" $search.fuse.findAllMatches "location" $search.fuse.location "threshold" $search.fuse.threshold "distance" $search.fuse.distance "ignoreLocation" $search.fuse.ignoreLocation "useExtendedSearch" $search.fuse.useExtendedSearch "ignoreFieldNorm" $search.fuse.ignoreFieldNorm | dict "search" | merge $config -}}
{{- end -}}
{{- end -}}
Expand Down

0 comments on commit a36cb5b

Please sign in to comment.