From 53b9acc9f0f9d81f3dd1719852c0ee6bcd4332f2 Mon Sep 17 00:00:00 2001 From: Brandon Rozek Date: Sun, 8 Jun 2025 19:39:56 -0400 Subject: [PATCH] Fetch website toots from API --- content/toots/_content.gotmpl | 40 +++++++++++++++++++++++++++++++++++ content/toots/_index.md | 8 +++++++ 2 files changed, 48 insertions(+) create mode 100644 content/toots/_content.gotmpl create mode 100644 content/toots/_index.md diff --git a/content/toots/_content.gotmpl b/content/toots/_content.gotmpl new file mode 100644 index 0000000..356088c --- /dev/null +++ b/content/toots/_content.gotmpl @@ -0,0 +1,40 @@ +{{/* Get remote data. */}} +{{ $items := dict }} +{{ $url := "https://api.brandonrozek.com/toots" }} +{{ with try (resources.GetRemote $url ) }} + {{ with .Err }} + {{ errorf "Unable to get remote resource %s: %s" $url . }} + {{ else with .Value }} + {{ $items = . | transform.Unmarshal }} + {{ else }} + {{ errorf "Unable to get remote resource %s" $url }} + {{ end }} +{{ end }} + +{{ range $items.toots }} + {{ $content := dict "mediaType" "text/html" "value" .content }} + {{ $dates := dict "date" (time.AsTime .created_at) }} + {{ $params := dict + "favourites_count" .favourites_count + "syndication" .url + "author" "@brozek@fosstodon.org" + "account" (dict + "display_name" "@brozek" + "avatar" "https://cdn.fosstodon.org/accounts/avatars/108/219/415/927/856/966/original/bae9f46f23936e79.jpg" + ) + "media_attachments" .media_attachments + "reblogs_count" .reblogs_count + "replies_count" .replies_count + + }} + {{ $page := dict + "content" $content + "dates" $dates + "kind" "page" + "params" $params + "path" .id + "title" "" + "build" (dict "render" "never") + }} + {{ $.AddPage $page }} +{{ end }} \ No newline at end of file diff --git a/content/toots/_index.md b/content/toots/_index.md new file mode 100644 index 0000000..2691576 --- /dev/null +++ b/content/toots/_index.md @@ -0,0 +1,8 @@ +--- +title: Toots +description: Brandon's Toots from Mastodon +--- + +This is an experimental page showing my toots from Mastodon. +Currently, this does not support boosts and it refreshes daily through a GitHub action. +Feel free to check out [my profile at Fosstodon](https://fosstodon.org/@brozek)