diff options
| author | eltrac <hi@eltr.ac> | 2026-04-02 09:10:53 +0800 |
|---|---|---|
| committer | eltrac <hi@eltr.ac> | 2026-04-02 09:10:53 +0800 |
| commit | bc2f34e733a95d697ec301eddfaca55c9f0e1cca (patch) | |
| tree | 551968a2c57073e012e360872c66f9b33d1d702f /layouts | |
| parent | 5f72c5ca3a77fd97eefcef2d475f853d2baaf72c (diff) | |
fix: temporary fix about microformats
Diffstat (limited to 'layouts')
| -rw-r--r-- | layouts/_partials/posts/webmention-mentions.html | 38 | ||||
| -rw-r--r-- | layouts/_partials/posts/webmention-replies.html | 35 | ||||
| -rw-r--r-- | layouts/_partials/posts/webmention-summary.html | 42 |
3 files changed, 90 insertions, 25 deletions
diff --git a/layouts/_partials/posts/webmention-mentions.html b/layouts/_partials/posts/webmention-mentions.html index ab6642a8..e4744bf7 100644 --- a/layouts/_partials/posts/webmention-mentions.html +++ b/layouts/_partials/posts/webmention-mentions.html @@ -4,15 +4,43 @@ {{ range . }} {{ if index . "microformats" }} {{ $mf := index . "microformats" "properties" }} - {{ $author := (index (index ($mf.author) 0) "properties") }} + {{ $author := dict }} + {{ if $mf.author }} + {{ if reflect.IsSlice $mf.author }} + {{ $authorElem := index $mf.author 0 }} + {{ if reflect.IsMap $authorElem }} + {{ $author = index $authorElem "properties" }} + {{ else }} + {{ $author = $authorElem }} + {{ end }} + {{ else }} + {{ $author = $mf.author }} + {{ end }} + {{ end }} {{ if eq (index .microformats.type 0) "h-card" }} {{ $author = $mf }} {{ end }} - {{ $photo := or (index . "extra" "proxied-photo") - (index $author.photo 0) }} + {{ $photo := "" }} + {{ $authorName := "" }} + {{ $authorUrl := "" }} + + {{ if reflect.IsMap $author }} + {{ $photo = or (index . "extra" "proxied-photo") (index $author.photo 0) }} + {{ $authorName = index $author.name 0 }} + {{ $authorUrl = index $author.url 0 }} + {{ else }} + {{ $photo = index . "extra" "proxied-photo" }} + {{ $authorName = $author }} + {{ $authorUrl = .webmention.source }} + {{ end }} + <li class="flex gap-2"> - <img src="{{ $photo }}" class="h-5 w-5 rd-full inline m-0"> - <a href="{{ index $author.url 0 }}" target="_blank">{{ index $author.name 0 }}</a> + {{ if $photo }} + <img src="{{ $photo }}" class="h-5 w-5 rd-full inline m-0"> + {{ else }} + <div class="h-5 w-5 rd-full m-0 bg-neutral-300"></div> + {{ end }} + <a href="{{ $authorUrl }}" target="_blank">{{ $authorName }}</a> <a href="{{ .webmention.source }}" target="_blank">{{ T "webmention.mentionedThisPost" . }}</a> </li> {{ else }} diff --git a/layouts/_partials/posts/webmention-replies.html b/layouts/_partials/posts/webmention-replies.html index e3f9658e..66b64ef9 100644 --- a/layouts/_partials/posts/webmention-replies.html +++ b/layouts/_partials/posts/webmention-replies.html @@ -2,20 +2,41 @@ <section class="flex flex-col gap-4 bg-[var(--background-color)]"> {{ range . }} {{ $reply := index . "microformats" "properties" }} - {{ $author := index (index $reply "author") 0 }} - {{ $author = index $author "properties" }} - {{ $photo := or (index $author.photo 0) (index $reply.photo 0) }} + {{ $author := dict }} + {{ $photo := "" }} + + {{ if $reply.author }} + {{ if reflect.IsSlice $reply.author }} + {{ $authorElem := index $reply.author 0 }} + {{ if reflect.IsMap $authorElem }} + {{ $author = index $authorElem "properties" }} + {{ else }} + {{ $author = $authorElem }} + {{ end }} + {{ $photo = or (index $author.photo 0) (index $reply.photo 0) }} + {{ else }} + {{ $author = $reply.author }} + {{ $photo = index $reply.photo 0 }} + {{ end }} + {{ end }} <div class="relative"> <header class="flex justify-between items-start"> <div class="flex items-center gap-3"> <img src="{{ $photo }}" alt="Profile Picture" class="h-8 w-8 rd-full" loading="lazy" /> - <div class="text-secondary"> + <div class="text-secondary"> <p class="font-bold m-0"> - <a href="{{ or (index $author.url 0) - (index $reply.url 0) }}"> - {{ replaceRE ":.*?:" "" (index $author.name 0) }} + <a href="{{ if reflect.IsMap $author }} + {{ or (index $author.url 0) (index $reply.url 0) }} + {{ else }} + {{ index $reply.url 0 }} + {{ end }}"> + {{ if reflect.IsMap $author }} + {{ replaceRE ":.*?:" "" (index $author.name 0) }} + {{ else }} + {{ $author }} + {{ end }} </a> </p> {{ $time := (index $reply.published 0) }} diff --git a/layouts/_partials/posts/webmention-summary.html b/layouts/_partials/posts/webmention-summary.html index a3a7265d..18be7344 100644 --- a/layouts/_partials/posts/webmention-summary.html +++ b/layouts/_partials/posts/webmention-summary.html @@ -13,19 +13,35 @@ </button> <!-- Likes --> - {{ range $likes }} - {{ $authors := index . "microformats" "properties" "author" }} - {{ $author := index (index $authors 0) "properties" }} - {{ $photo := or (index . "extra" "proxied-photo") - (index $author.photo 0) }} - <a href="{{ index $author.url 0 }}" target="_blank" title="{{ index $author.name 0 }}" class="box-border hover:no-underline inline-block h-5 w-5 float-left -ml-1 hover:scale-150 transition-transform"> - {{ $value := math.Floor (mul math.Rand 80) }} - {{ $rotate := cond (lt $value 40) (sub 10 $value) (sub $value 30) }} - <img src="{{ $photo }}" alt="Profile Picture" - loading="lazy" - class="h-5 w-5 rd-full transition-transform" - style="{{ if ne $rotate 0 }}--rotate-amount: {{ $rotate }}deg;{{ end }}" /> - </a> + {{ range $likes }} + {{ $authors := index . "microformats" "properties" "author" }} + {{ $author := dict }} + {{ $photo := "" }} + {{ if $authors }} + {{ if reflect.IsSlice $authors }} + {{ $authorElem := index $authors 0 }} + {{ if reflect.IsMap $authorElem }} + {{ $author = index $authorElem "properties" }} + {{ else }} + {{ $author = $authorElem }} + {{ end }} + {{ else }} + {{ $author = $authors }} + {{ end }} + {{ end }} + {{ $photo = or (index . "extra" "proxied-photo") (index $author.photo 0) }} + <a href="{{ if reflect.IsMap $author }}{{ index $author.url 0 }}{{ else }}#{{ end }}" target="_blank" title="{{ if reflect.IsMap $author }}{{ index $author.name 0 }}{{ else }}{{ $author }}{{ end }}" class="box-border hover:no-underline inline-block h-5 w-5 float-left -ml-1 hover:scale-150 transition-transform"> + {{ $value := math.Floor (mul math.Rand 80) }} + {{ $rotate := cond (lt $value 40) (sub 10 $value) (sub $value 30) }} + {{ if $photo }} + <img src="{{ $photo }}" alt="Profile Picture" + loading="lazy" + class="h-5 w-5 rd-full transition-transform" + style="{{ if ne $rotate 0 }}--rotate-amount: {{ $rotate }}deg;{{ end }}" /> + {{ else }} + <div class="h-5 w-5 rd-full bg-neutral-300"></div> + {{ end }} + </a> {{ end }} <div class="text-secondary m-0 text-sm inline ml-2"> {{ printf (T "webmention.likedBy") (len $likes ) }} |
