cremeaux/layouts/partials/article-preview.html

31 lines
1.3 KiB
HTML
Raw Normal View History

{{ $isBig := default false (.Scratch.Get "big") }}
{{ $title := .RenderString .Title }}
{{ $titleWithoutHTML := $title | plainify }}
2021-05-03 14:57:56 +02:00
{{ $pictureSize := cond $isBig "220x220 Center webp" "100x100 Center webp" }}
{{ $truncateSize := cond $isBig 180 90}}
<div class="post{{ if $isBig }} big{{ end }}">
<div class="picture">
2021-04-08 17:27:37 +02:00
{{ $image := .Resources.GetMatch (default "**.jpg" .Params.image) }}
<a href="{{ .RelPermalink }}">
{{ if $image }}
{{ $resized := $image.Fill $pictureSize}}
<img src="{{ $resized.RelPermalink }}" alt="{{ $titleWithoutHTML }}" loading="lazy" />
{{ end }}
</a>
</div>
<div class="details">
<small>
<time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Day }} {{ index $.Site.Data.mois (printf "%d" .Date.Month) }} {{ .Date.Year }}</time>{{ if isset .Params "auteur" }} - {{ .Params.auteur }}{{ end }}
</small>
{{ if $isBig }}
<h2 title="{{ $titleWithoutHTML }}"><a href="{{ .RelPermalink }}">{{ $title }}</a></h2>
{{else}}
<h3 title="{{ $titleWithoutHTML }}"><a href="{{ .RelPermalink }}">{{ $title }}</a></h3>
{{ end }}
<div class="text">
{{ $ellipsis := print " <a href='" .RelPermalink "'></a>" | safeHTML }}
{{ (replace (.Content | plainify) "\n" " ") | htmlUnescape | truncate $truncateSize $ellipsis }}
</div>
</div>
</div>