From d8bdf7e3164abb117c03a0c79883b2d391de0048 Mon Sep 17 00:00:00 2001 From: ZhenShuo Leo <98386542+ZhenShuo2021@users.noreply.github.com> Date: Sun, 13 Jul 2025 19:56:39 +0800 Subject: [PATCH 1/2] chore: add warn message for GetRemote usage in shortcodes --- layouts/shortcodes/codeberg.html | 2 ++ layouts/shortcodes/codeimporter.html | 4 ++-- layouts/shortcodes/forgejo.html | 2 ++ layouts/shortcodes/gitea.html | 2 ++ layouts/shortcodes/github.html | 2 ++ layouts/shortcodes/mdimporter.html | 2 +- 6 files changed, 11 insertions(+), 3 deletions(-) diff --git a/layouts/shortcodes/codeberg.html b/layouts/shortcodes/codeberg.html index 067175f9..ccaeca18 100644 --- a/layouts/shortcodes/codeberg.html +++ b/layouts/shortcodes/codeberg.html @@ -56,4 +56,6 @@ data-repo-id="{{ $id }}"> +{{- else -}} + {{ warnf "codeberg shortcode: unable to fetch %q: %s" $codebergURL .Position }} {{- end -}} diff --git a/layouts/shortcodes/codeimporter.html b/layouts/shortcodes/codeimporter.html index e4467ddf..6ecdc003 100644 --- a/layouts/shortcodes/codeimporter.html +++ b/layouts/shortcodes/codeimporter.html @@ -15,7 +15,7 @@ {{ end }} {{ if gt $startLine $endLine }} - {{ errorf "Code Importer Shortcode - startLine is greater than endLine" . }} + {{ errorf "codeimporter shortcode: startLine is greater than endLine" . }} {{ end }} {{ $selectedLines := first $endLine $lines }} @@ -23,5 +23,5 @@ {{ $codeBlock := printf "```%s\n%s\n```" $type (delimit $selectedLines "\n") }} {{ $codeBlock | markdownify }} {{ else }} - {{ errorf "Code Importer Shortcode - Unable to get remote resource" . }} + {{ warnf "codeimporter shortcode: unable to fetch %q: %s" $url .Position }} {{ end }} diff --git a/layouts/shortcodes/forgejo.html b/layouts/shortcodes/forgejo.html index 666f5f0a..775a3a59 100644 --- a/layouts/shortcodes/forgejo.html +++ b/layouts/shortcodes/forgejo.html @@ -56,4 +56,6 @@ data-repo-id="{{ $id }}"> +{{- else -}} + {{ warnf "forgejo shortcode: unable to fetch %q: %s" $forgejoURL .Position }} {{- end -}} diff --git a/layouts/shortcodes/gitea.html b/layouts/shortcodes/gitea.html index 511ee4ae..fcf0f8fb 100644 --- a/layouts/shortcodes/gitea.html +++ b/layouts/shortcodes/gitea.html @@ -56,4 +56,6 @@ data-repo-id="{{ $id }}"> +{{- else -}} + {{ warnf "gitea shortcode: unable to fetch %q: %s" $giteaURL .Position }} {{- end -}} diff --git a/layouts/shortcodes/github.html b/layouts/shortcodes/github.html index d333972b..8cd33c01 100644 --- a/layouts/shortcodes/github.html +++ b/layouts/shortcodes/github.html @@ -71,5 +71,7 @@ data-repo-url="{{ $githubURL }}" data-repo-id="{{ $id }}"> + {{- else -}} + {{ warnf "github shortcode: unable to fetch %q: %s" $githubURL .Position }} {{- end -}} diff --git a/layouts/shortcodes/mdimporter.html b/layouts/shortcodes/mdimporter.html index db50adba..2b7bab9c 100644 --- a/layouts/shortcodes/mdimporter.html +++ b/layouts/shortcodes/mdimporter.html @@ -2,5 +2,5 @@ {{ with resources.GetRemote (urls.Parse $url) }} {{ .Content | markdownify }} {{ else }} - {{ errorf "Mardown Importer Shortcode - Unable to get remote resource" . }} + {{ warnf "mdimporter shortcode: unable to fetch %q: %s" $url .Position }} {{ end }} From 237c90afa93b791f66d044ab04210f9357d3806c Mon Sep 17 00:00:00 2001 From: ZhenShuo Leo <98386542+ZhenShuo2021@users.noreply.github.com> Date: Sun, 13 Jul 2025 20:08:32 +0800 Subject: [PATCH 2/2] chore(github.html): move div into with syntax --- layouts/shortcodes/github.html | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/layouts/shortcodes/github.html b/layouts/shortcodes/github.html index 8cd33c01..05be3d4e 100644 --- a/layouts/shortcodes/github.html +++ b/layouts/shortcodes/github.html @@ -4,9 +4,8 @@ {{- $githubThumbnailURL := print "https://opengraph.githubassets.com/0/" (.Get "repo") -}} {{- $showThumbnail := .Get "showThumbnail" | default true -}} - -
- {{- with $githubData -}} +{{- with $githubData -}} +
@@ -71,7 +70,7 @@ data-repo-url="{{ $githubURL }}" data-repo-id="{{ $id }}"> - {{- else -}} - {{ warnf "github shortcode: unable to fetch %q: %s" $githubURL .Position }} - {{- end -}} -
+
+{{- else -}} + {{ warnf "github shortcode: unable to fetch %q: %s" $githubURL .Position }} +{{- end -}}