You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

18 lines
689 B

{{- with .Get "url" }}
{{- $u := urls.Parse . }}
{{- $qs := collections.Querify (dict "url" $u.String) }}
{{- $api := printf "https://%s/api/oembed?%s" $u.Host $qs }}
{{- with try (resources.GetRemote $api) }}
{{- with .Err }}
{{- errorf "%s" . }}
{{- else with .Value }}
{{- with . | transform.Unmarshal }}
{{- .html | safeHTML }}
{{- end }}
{{- else }}
{{- warnidf "shortcode-mastodon" "The %q shortcode was unable to retrieve the remote data. See %s" $.Name $.Position }}
{{- end }}
{{- end }}
{{- else }}
{{- errorf "The %q shortcode requires a positional parameter: the url of the post. See %s" .Name .Position }}
{{- end }}