From f34ee49d2bb7a3cf2c2ca9837cb791564cdfe3b1 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Mon, 30 Sep 2024 01:20:12 +0530 Subject: [PATCH] Fix getJSON deprecation --- layouts/shortcodes/external-content.html | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/layouts/shortcodes/external-content.html b/layouts/shortcodes/external-content.html index ddc4591..b765b3e 100644 --- a/layouts/shortcodes/external-content.html +++ b/layouts/shortcodes/external-content.html @@ -7,13 +7,25 @@ {{ if isset .Params 0 }} {{ $url := index .Params 0 }} - {{ with getJSON $url }} - {{ .content | base64Decode | replaceRE "(?m)^# (.+)$" "## $1" | markdownify }} - {{ else }} - {{ errorf "Failed to fetch content from the provided URL: %s" $url }} - {{ end }} + {{ with resources.GetRemote $url }} + {{ with .Err }} + {{ errorf "%s" . }} + {{ else }} + {{ with . | transform.Unmarshal }} + {{ with .content }} + {{ . | base64Decode | replaceRE "(?m)^# (.+)$" "## $1" | markdownify }} + {{ else }} + {{ errorf "No 'content' field found in the response" }} + {{ end }} + {{ else }} + {{ errorf "Failed to unmarshal the response" }} + {{ end }} + {{ end }} + {{ else }} + {{ errorf "Unable to get remote resource %q" $url }} + {{ end }} {{ else }} {{ errorf "You must provide a URL in the shortcode." }} {{ end }} - + \ No newline at end of file