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

View File

@@ -1,7 +1,16 @@
{{ $id := delimit (slice "gitlab" (partial "functions/uid.html" .)) "-" }}
{{- $gitlabURL := print (default "https://gitlab.com/" (.Get "baseURL")) "api/v4/projects/" (.Get "projectID") -}}
{{- $gitLabData := dict -}}
{{- with try (resources.GetRemote $gitlabURL) -}}
{{- with .Err -}}
{{- warnf "gitlab shortcode: failed to fetch remote resource from %q: %s" $gitlabURL .Position -}}
{{- else with .Value -}}
{{- $gitLabData = . | transform.Unmarshal -}}
{{- else -}}
{{- warnf "gitlab shortcode: unable to get remote resource from %q: %s" $gitlabURL .Position -}}
{{- end -}}
{{- end -}}
{{- $gitLabData := resources.GetRemote $gitlabURL | transform.Unmarshal -}}
{{- with $gitLabData -}}
<div class="gitlab-card-wrapper">
<a id="{{ $id }}" target="_blank" href="{{ .web_url }}" class="cursor-pointer">