{{- $url := .Get 0 -}} {{- $parsed := urls.Parse $url -}} {{- $parts := split $parsed.Path "/" -}} {{- $id := index $parts (sub (len $parts) 1) -}} {{- $instance := printf "%s://%s" $parsed.Scheme $parsed.Host -}} {{- $apiUrl := printf "%s/api/v1/statuses/%s" $instance $id -}} {{- $data := resources.GetRemote $apiUrl -}} {{- $json := $data | transform.Unmarshal -}} {{- $author := $json.account -}} {{- $publishedAt := time $json.created_at -}} {{- $avatarSrc := $author.avatar -}} {{- with resources.GetRemote $author.avatar -}} {{- with .Resize "88x88 q85 webp" -}} {{- $avatarSrc = .RelPermalink -}} {{- end -}} {{- end -}} {{- /* Count image attachments */ -}} {{- $imgCount := 0 -}} {{- range $json.media_attachments -}}{{- if eq .type "image" -}}{{- $imgCount = add $imgCount 1 -}}{{- end -}}{{- end -}} {{- $cId := printf "sc-%s" (md5 $url) -}} {{- $dId := printf "sd-%s" (md5 $url) -}}
{{ $author.display_name }} @{{ $author.acct }}
{{- $bodyText := $json.content -}} {{- $bodyText = $bodyText | replaceRE `(

[\s]*(]*class="mention hashtag"[^>]*>#[^<]+[\s]*)+

[\s]*)+$` "" -}} {{- $bodyText = $bodyText | replaceRE `` "" -}} {{- $bodyText = $bodyText | replaceRE `` `

` -}} {{- $bodyText = $bodyText | replaceRE `

]+>[\s]*

` "" -}}
{{ $bodyText | safeHTML }}
{{- if gt $imgCount 0 -}} {{- if le $imgCount 2 -}} {{- /* 1–2 images: flex row (2 images split 50/50, cropped) */ -}}
{{- range $json.media_attachments -}} {{- if eq .type "image" -}} {{- $imgSrc := .preview_url -}} {{- with resources.GetRemote .preview_url -}} {{- with .Process "q85 webp" -}} {{- $imgSrc = .RelPermalink -}} {{- end -}} {{- end -}} {{ .description }} {{- end -}} {{- end -}}
{{- else -}} {{- /* 3+ images: scroll-snap carousel */ -}}
{{- range $json.media_attachments -}} {{- if eq .type "image" -}} {{- $imgSrc := .preview_url -}} {{- with resources.GetRemote .preview_url -}} {{- with .Process "q85 webp" -}} {{- $imgSrc = .RelPermalink -}} {{- end -}} {{- end -}} {{ .description }} {{- end -}} {{- end -}}
{{- $imgAttachments := slice -}} {{- range $json.media_attachments -}}{{- if eq .type "image" -}}{{- $imgAttachments = $imgAttachments | append . -}}{{- end -}}{{- end -}}
{{- range $i, $_ := $imgAttachments -}} {{- end -}}
{{- end -}} {{- end -}} {{- /* Link preview card — use original image URL, skip processing (CDN images can return 403) */ -}} {{- with $json.card -}} {{- if or (eq .type "link") (eq .type "photo") (eq .type "video") -}}
{{- if .image -}} {{ .title }} {{- end -}}
{{ .title }}
{{- if .description -}}
{{ .description }}
{{- end -}}
{{ (urls.Parse .url).Host }}
{{- end -}} {{- end -}}
{{ T "ViewOnFediverse" . }}
{{- /* Shared lightbox — injected once per page via DOM API (no innerHTML) */ -}}