From 2c1cefd461ee56ef7d56fd6fc80057fcf3f2bb9a Mon Sep 17 00:00:00 2001 From: Brandon Rozek Date: Sun, 15 May 2022 20:37:37 -0400 Subject: [PATCH] Added shortcode to display a toot by querying Mastodon --- layouts/shortcodes/displayOnlineToot.html | 31 +++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 layouts/shortcodes/displayOnlineToot.html diff --git a/layouts/shortcodes/displayOnlineToot.html b/layouts/shortcodes/displayOnlineToot.html new file mode 100644 index 0000000..67b9b46 --- /dev/null +++ b/layouts/shortcodes/displayOnlineToot.html @@ -0,0 +1,31 @@ +{{ $url := urls.Parse (.Get 0) }} +{{ $status_id := index (last 1 (split $url.Path "/")) 0 }} +{{ $api_url := printf "%s://%s/api/v1/statuses/%s" $url.Scheme $url.Host $status_id }} +{{ $dataJ := getJSON $api_url }} + +{{ with $dataJ }} +{{ if ne .content "" }} +
+
+ +

Tooted on

+ {{ .content | safeHTML }} + {{ if gt (len .media_attachments) 0 }} +
+ {{ range .media_attachments}} + {{ if eq .type "image" }} + {{ .description }} + {{ end }} + {{ end }} +
+ {{ end }} +
+
+ {{ .replies_count }} + {{ .reblogs_count }} + {{ .favourites_count }} + | Source: {{ .url }} +
+
+{{ end }} +{{ end }}