From ecf6d1d53fa67f8cff71ade76acf38826b7310a9 Mon Sep 17 00:00:00 2001 From: ZhenShuo Leo <98386542+ZhenShuo2021@users.noreply.github.com> Date: Thu, 17 Jul 2025 23:09:00 +0800 Subject: [PATCH] chore(repo-card): add try statement at GetRemote --- config.toml | 2 +- layouts/shortcodes/codeberg.html | 12 +++++++++++- layouts/shortcodes/forgejo.html | 12 +++++++++++- layouts/shortcodes/gitea.html | 12 +++++++++++- layouts/shortcodes/github.html | 11 ++++++++++- layouts/shortcodes/gitlab.html | 11 ++++++++++- 6 files changed, 54 insertions(+), 6 deletions(-) diff --git a/config.toml b/config.toml index 0a97846b..ab99d8c8 100644 --- a/config.toml +++ b/config.toml @@ -1,5 +1,5 @@ [module] [module.hugoVersion] extended = true -min = "0.137.0" +min = "0.141.0" max = "0.148.0" \ No newline at end of file diff --git a/layouts/shortcodes/codeberg.html b/layouts/shortcodes/codeberg.html index ccaeca18..787db9e4 100644 --- a/layouts/shortcodes/codeberg.html +++ b/layouts/shortcodes/codeberg.html @@ -1,6 +1,16 @@ {{ $id := delimit (slice "codeberg" (partial "functions/uid.html" .)) "-" }} {{- $codebergURL := print "https://codeberg.org/api/v1/repos/" (.Get "repo") -}} -{{- $codebergData := resources.GetRemote $codebergURL | transform.Unmarshal -}} +{{- $codebergData := dict -}} +{{- with try (resources.GetRemote $codebergURL) -}} + {{- with .Err -}} + {{- warnf "codeberg shortcode: failed to fetch remote resource from %q: %s" $codebergURL .Position -}} + {{- else with .Value -}} + {{- $codebergData = . | transform.Unmarshal -}} + {{- else -}} + {{- warnf "codeberg shortcode: unable to get remote resource from %q: %s" $codebergURL .Position -}} + {{- end -}} +{{- end -}} + {{- with $codebergData -}}