yequari.com/layouts/partials/statuscafe.html

37 lines
1.1 KiB
HTML

{{ $data := dict }}
{{ $url := "https://status.cafe/users/yequari/status.json" }}
{{ with resources.GetRemote $url }}
{{ with .Err }}
{{ errorf "%s" . }}
{{ else }}
<div id="statuscafe">
{{ $data = .Content | transform.Unmarshal }}
{{ $length := len $data.content }}
{{ if eq $length 0 }}
No status
{{ else }}
{{ $timestrs := strings.Split $data.timeAgo " " }}
{{ $timeamt := index $timestrs 0 }}
{{ $timeunit := index $timestrs 1 }}
{{ $timeunit = strings.Substr $timeunit 0 1 }}
{{ $url = "https://status.cafe/users/yequari/badge.png" }}
{{ with resources.GetRemote $url}}
<div id="statuscafe-username">
<a href="https://status.cafe/users/yequari"><img src="{{ .RelPermalink }}" alt="Status Cafe Profile"/></a>
</div>
{{ end }}
<div id="statuscafe-timeago">
🕗{{ $timeamt }}{{ $timeunit }}
</div>
<div id="statuscafe-content">
<p>
{{ htmlUnescape $data.content }}
</p>
</div>
</div>
{{ end }}
{{ end }}
{{ else }}
{{ errorf "Unable to get remote resource %q" $url }}
{{ end }}