mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 15:28:57 +00:00
perf: add bluesky shortcode with remote JSON retrieval and styling
This commit is contained in:
@@ -1,11 +1,18 @@
|
||||
{{- $response := dict -}}
|
||||
{{- with try (resources.GetRemote .URL .OPTIONS) -}}
|
||||
{{- with .Err -}}
|
||||
{{- erroridf "error-get-remote-json" "%s" . -}}
|
||||
{{- else with .Value -}}
|
||||
{{- $response = .Content | transform.Unmarshal -}}
|
||||
{{- else -}}
|
||||
{{- erroridf "error-get-remote-json" "Unable to get remote resource %q" $.URL -}}
|
||||
{{- $url := .URL -}}
|
||||
{{- $options := .OPTIONS | default dict -}}
|
||||
|
||||
{{- if $url -}}
|
||||
{{- $cacheKey := print $url (now.Format "2006-01-02") -}}
|
||||
{{- $options = $options | merge (dict "key" $cacheKey) -}}
|
||||
{{- with try (resources.GetRemote $url $options) -}}
|
||||
{{- with .Err -}}
|
||||
{{- erroridf "error-get-remote-json" "%s" . -}}
|
||||
{{- else with .Value -}}
|
||||
{{- $response = .Content | transform.Unmarshal -}}
|
||||
{{- else -}}
|
||||
{{- erroridf "error-get-remote-json" "Failed to get remote JSON %q" $url -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user