feat(layouts): add timeout and cache key options to get-remote-image partial

This commit is contained in:
Cell
2026-07-19 15:33:15 +08:00
parent 10da1f731f
commit 0d6af76f06
3 changed files with 6 additions and 3 deletions
@@ -1,9 +1,12 @@
{{- /* cache remote image locally */ -}}
{{- $resource := 0 -}}
{{- $options := .OPTIONS | default dict -}}
{{- $cacheKey := print .Src (now.Format "2006-01-02") -}}
{{- $options = $options | merge (dict "key" $cacheKey "timeout" "3s") -}}
{{- $isRemote := urls.Parse .Src | partial "function/is-url-remote.html" -}}
{{- if $isRemote -}}
{{- with try (resources.GetRemote .Src) -}}
{{- with try (resources.GetRemote .Src $options) -}}
{{- with .Err -}}
{{- warnidf "warning-remote-image" "%s" . -}}
{{- else with .Value -}}
@@ -7,7 +7,7 @@
{{- end -}}
{{- $cacheKey := print $url (now.Format "2006-01-02") -}}
{{- $options = $options | merge (dict "key" $cacheKey) -}}
{{- $options = $options | merge (dict "key" $cacheKey "timeout" "3s") -}}
{{- with try (resources.GetRemote $url $options) -}}
{{- with .Err -}}
{{- erroridf "error-get-remote-json" "%s" . -}}
+1 -1
View File
@@ -1,4 +1,4 @@
{{- hugo.Store.Set "version" "v1.0.0-mrrceo88" -}}
{{- hugo.Store.Set "version" "v1.0.0-mrrhb8pg" -}}
{{- .Store.Set "this" dict -}}
{{- partial "init/detection-env.html" . -}}