Skip to content

Commit

Permalink
Fix getJSON deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
agriyakhetarpal committed Sep 29, 2024
1 parent cc95e8f commit f34ee49
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions layouts/shortcodes/external-content.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,25 @@
<body>
{{ 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 }}
</body>
</html>
</html>

0 comments on commit f34ee49

Please sign in to comment.