mirror of
https://github.com/Brandon-Rozek/website.git
synced 2025-08-03 23:31:59 +00:00
Fetch website toots from API
This commit is contained in:
parent
d3434eff06
commit
53b9acc9f0
2 changed files with 48 additions and 0 deletions
40
content/toots/_content.gotmpl
Normal file
40
content/toots/_content.gotmpl
Normal file
|
@ -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 }}
|
8
content/toots/_index.md
Normal file
8
content/toots/_index.md
Normal file
|
@ -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)
|
Loading…
Add table
Reference in a new issue