mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 23:38:56 +00:00
5322a15ceb
Add `{{/* ... */}}` header comments to 25 partials that had no documentation,
enabling `pnpm gen:docs` to generate their reference docs. Also fix
base/head/index.html leading blank line that prevented parser matching.
Groups covered: base/, feed/, function/, home/, init/, plugin/, single/, store/, (root).
30 lines
950 B
HTML
30 lines
950 B
HTML
{{- /*
|
|
Fetch and parse remote JSON with daily caching.
|
|
|
|
@param {String} .URL - The remote JSON URL (required)
|
|
@param {Object} [.OPTIONS] - Additional options for resources.GetRemote
|
|
@return {Object} The parsed JSON response, or empty dict on failure
|
|
*/ -}}
|
|
|
|
{{- $response := dict -}}
|
|
{{- $url := .URL -}}
|
|
{{- $options := .OPTIONS | default dict -}}
|
|
|
|
{{- if not $url -}}
|
|
{{- erroridf "error-get-remote-json" "URL parameter is required!" -}}
|
|
{{- end -}}
|
|
|
|
{{- $cacheKey := print $url (now.Format "2006-01-02") -}}
|
|
{{- $options = $options | merge (dict "key" $cacheKey "timeout" "3s") -}}
|
|
{{- 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 -}}
|
|
|
|
{{- return $response -}}
|