Files
pivoine.art/layouts/partials/post-card.html
T
2026-04-08 19:49:15 +02:00

64 lines
2.5 KiB
HTML

{{- /* Compact post card for grids.
Expects a post page as context (.).
*/ -}}
{{- $post := . -}}
<article class="group card-comic flex flex-col bg-concrete">
<a href="{{ $post.RelPermalink }}" class="block flex-1 flex flex-col">
<!-- Thumbnail — bundle banner.png → 01.png → .Params.banner -->
{{- $thumb := $post.Resources.GetMatch "banner.png" -}}
{{- if not $thumb -}}{{- $thumb = $post.Resources.GetMatch "01.png" -}}{{- end -}}
<div class="card-media aspect-editorial">
{{- if $thumb -}}
<img class="w-full h-full object-cover" src="{{ $thumb.RelPermalink }}" alt="{{ $post.Title }}" loading="lazy" decoding="async">
{{- else -}}{{- with $post.Params.banner -}}
{{- partial "media.html" (dict "media" . "class" "w-full h-full object-cover") -}}
{{- else -}}
<div class="w-full h-full flex items-center justify-center halftone">
<span class="label text-smoke text-xs">PIVOINE</span>
</div>
{{- end -}}{{- end -}}
</div>
<!-- Category badge — parallelogram -->
{{- with $post.Params.categories -}}
<div class="flex flex-wrap gap-2 px-4 pt-4">
{{- range first 1 . -}}
<span class="badge">{{ . }}</span>
{{- end -}}
</div>
{{- end -}}
<!-- Title -->
<h3 class="font-display text-base md:text-lg text-paper text-balance leading-none group-hover:text-heat transition-colors px-4 pt-3 pb-2 flex-1">
{{- $post.Title -}}
</h3>
<!-- Author + date -->
<div class="flex items-center gap-2 px-4 pb-4 mt-auto pt-3 border-t border-zinc">
{{- with $post.Params.author -}}
{{- $authorPage := site.GetPage (printf "authors/%s" .) -}}
{{- with $authorPage -}}
{{- $avRes := .Resources.GetMatch "avatar.*" -}}
{{- $avSrc := "" -}}
{{- with $avRes }}{{ $avSrc = .RelPermalink }}{{ else }}{{ with $.Params.avatar }}{{ $avSrc = . }}{{ end }}{{ end -}}
{{- with $avSrc -}}
<img
src="{{ . }}"
alt="{{ $authorPage.Params.name | default $authorPage.Title }}"
class="w-5 h-5 object-cover border border-smoke flex-shrink-0"
loading="lazy"
>
{{- end -}}
<span class="label text-fog">{{ .Params.name | default .Title }}</span>
<span class="text-smoke" aria-hidden="true">/</span>
{{- end -}}
{{- end -}}
<time class="label text-fog" datetime="{{ $post.Date.Format "2006-01-02" }}">
{{- $post.Date.Format "Jan 2006" -}}
</time>
</div>
</a>
</article>