mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 15:28:57 +00:00
feat(layouts): add timeout and cache key options to get-remote-image partial
This commit is contained in:
@@ -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,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" . -}}
|
||||
|
||||
Reference in New Issue
Block a user