chore(repo-card): add try statement at GetRemote

This commit is contained in:
ZhenShuo Leo
2025-07-17 23:09:00 +08:00
parent 237c90afa9
commit ecf6d1d53f
6 changed files with 54 additions and 6 deletions
+11 -1
View File
@@ -1,6 +1,16 @@
{{ $id := delimit (slice "gitea" (partial "functions/uid.html" .)) "-" }}
{{- $giteaURL := print (.Get "server" | default .Site.Params.giteaDefaultServer) "/api/v1/repos/" (.Get "repo") -}}
{{- $giteaData := resources.GetRemote $giteaURL | transform.Unmarshal -}}
{{- $giteaData := dict -}}
{{- with try (resources.GetRemote $giteaURL) -}}
{{- with .Err -}}
{{- warnf "gitea shortcode: failed to fetch remote resource from %q: %s" $giteaURL .Position -}}
{{- else with .Value -}}
{{- $giteaData = . | transform.Unmarshal -}}
{{- else -}}
{{- warnf "gitea shortcode: unable to get remote resource from %q: %s" $giteaURL .Position -}}
{{- end -}}
{{- end -}}
{{- with $giteaData -}}
<div class="gitea-card-wrapper">
<a id="{{ $id }}" target="_blank" href="{{ .html_url }}" class="cursor-pointer">