Erstes Commit
This commit is contained in:
19
hugo/layouts/partials/available-currencies.html
Normal file
19
hugo/layouts/partials/available-currencies.html
Normal file
@@ -0,0 +1,19 @@
|
||||
{{ $pbBase := getenv "POCKETBASE_URL" | default site.Params.pocketbase_url }}
|
||||
{{ $pbUrl := printf "%s/api/collections/currencies/records" $pbBase }}
|
||||
{{ $pbOpts := dict "method" "GET" "timeout" "15s" "headers" (dict "Accept" (slice "application/json")) }}
|
||||
{{ $pbCurrencies := slice }}
|
||||
{{ $pbOk := false }}
|
||||
{{ with try (resources.GetRemote $pbUrl $pbOpts) }}
|
||||
{{ with .Err }}
|
||||
{{ else with .Value }}
|
||||
{{ with transform.Unmarshal .Content }}
|
||||
{{ if .items }}
|
||||
{{ range $record := .items }}
|
||||
{{ $pbCurrencies = $pbCurrencies | append (lower $record.id) }}
|
||||
{{ end }}
|
||||
{{ $pbOk = true }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ return dict "ok" $pbOk "currencies" ($pbCurrencies | append "eur") }}
|
||||
Reference in New Issue
Block a user