1
Files
2025/themes/default/layouts/partials/articles-list.html
2025-03-28 12:57:37 +01:00

62 lines
2.4 KiB
HTML

{{- $pages := .Pages -}}
{{- $context := .Context -}}
<div class="articles-grid">
{{ range $pages -}}
<a href="{{ .RelPermalink }}" class="article-card">
{{ $page := . -}}
{{- $coverPath := .Params.cover -}}
{{- $img := false -}}
{{- if $coverPath -}}
{{- if strings.HasSuffix $coverPath ".yaml" -}}
{{- $coverAbsPath := printf "%s%s" $page.File.Dir $coverPath -}}
{{- $coverRaw := readFile $coverAbsPath -}}
{{- $coverData := $coverRaw | transform.Unmarshal -}}
{{- with $coverData.file -}}
{{- $img = $page.Resources.GetMatch . -}}
{{- end -}}
{{- else -}}
{{- $img = $page.Resources.GetMatch $coverPath -}}
{{- end -}}
{{- end -}}
{{- if $img -}}
{{- with $img -}}
{{- $resized := .Resize "650x" -}}
<div class="article-image" style="background-image: url('{{ $resized.RelPermalink }}');">
{{ with $page.Params.date -}}
<span class="article-date">{{ $page.Date | time.Format ":date_long" }}</span>
{{- end }}
</div>
{{ end -}}
{{- else -}}
<div class="article-image" style="background: linear-gradient(135deg, #222 0%, #111 100%);">
{{ with $page.Params.date -}}
<span class="article-date">{{ $page.Date | time.Format ":date_long" }}</span>
{{- end }}
</div>
{{- end }}
<div class="article-content">
<h3 class="article-title">{{ .Title }}</h3>
<div class="article-meta">
{{ $section := "" -}}
{{- with .Parent -}}
{{- $sectionPath := path.Base .File.Dir -}}
{{- $section = $sectionPath -}}
{{- end -}}
<span class="section section-{{ $section }}">{{ .Parent.LinkTitle }}</span>
<span class="reading-time">
{{ if .IsSection -}}
{{- $count := len .Pages -}}
{{- $label := cond (eq $count 1) "article" "articles" -}}
{{- $count }} {{ $label -}}
{{- else -}}
{{- if ge .ReadingTime 5 -}}
{{- .ReadingTime }} min de lecture
{{- end -}}
{{- end }}
</span>
</div>
</div>
</a>
{{ end }}
</div>