refactor(search): support local/mirrored FlexSearch assets (#956)
* feat(search): support local and mirrored FlexSearch assets Add params.search.flexsearch.base/js overrides in search script loading. Document offline/local and mirror-based script asset configuration examples. * refactor(scripts): normalize remote asset URL joins * docs(config): clarify local asset examples * docs(i18n): add local asset config guidance
This commit is contained in:
@@ -39,7 +39,7 @@
|
||||
{{- $minSuffix := cond hugo.IsProduction ".min" "" -}}
|
||||
{{- if $isRemoteBase -}}
|
||||
{{- $cssPath := cond (ne $katexCssAsset "") $katexCssAsset (printf "katex%s.css" $minSuffix) -}}
|
||||
{{- $katexCssUrl := printf "%s/%s" $katexBase $cssPath -}}
|
||||
{{- $katexCssUrl := urls.JoinPath $katexBase $cssPath -}}
|
||||
{{- with try (resources.GetRemote $katexCssUrl) -}}
|
||||
{{- with .Err -}}
|
||||
{{- errorf "Could not retrieve KaTeX css file from %s. Reason: %s." $katexCssUrl . -}}
|
||||
@@ -59,7 +59,7 @@
|
||||
{{- $cssContent := . -}}
|
||||
{{- if $isRemoteBase -}}
|
||||
{{- $fontPattern := "url(fonts/" -}}
|
||||
{{- $fontSub := printf "url(%s/fonts/" $katexBase -}}
|
||||
{{- $fontSub := printf "url(%s/" (urls.JoinPath $katexBase "fonts") -}}
|
||||
{{- $cssContent = strings.Replace $cssContent $fontPattern $fontSub -}}
|
||||
{{- end -}}
|
||||
{{- with resources.FromString (printf "css/katex%s.css" $minSuffix) $cssContent -}}
|
||||
@@ -69,7 +69,7 @@
|
||||
{{- else -}}
|
||||
{{- if not $isRemoteBase -}}
|
||||
{{- $cssPath := cond (ne $katexCssAsset "") $katexCssAsset (printf "katex%s.css" $minSuffix) -}}
|
||||
<link rel="stylesheet" href="{{ printf "%s/%s" $katexBase $cssPath }}" />
|
||||
<link rel="stylesheet" href="{{ urls.JoinPath $katexBase $cssPath }}" />
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user