Refond la page d’accueil
This commit is contained in:
41
themes/default/layouts/partials/featured-card.html
Normal file
41
themes/default/layouts/partials/featured-card.html
Normal file
@@ -0,0 +1,41 @@
|
||||
{{- $page := .Page -}}
|
||||
{{- $coverPath := $page.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 -}}
|
||||
|
||||
<article class="featured-card">
|
||||
<a class="featured-card__image" href="{{ $page.RelPermalink }}">
|
||||
{{- if $img -}}
|
||||
{{- $resized := $img.Resize "640x" -}}
|
||||
<img src="{{ $resized.RelPermalink }}" alt="{{ default $page.Title $page.Params.cover_alt }}" loading="lazy" />
|
||||
{{- else -}}
|
||||
<div class="featured-card__image--placeholder" aria-hidden="true"></div>
|
||||
{{- end -}}
|
||||
</a>
|
||||
<div class="featured-card__body">
|
||||
<div class="featured-card__meta">
|
||||
{{- with $page.Parent }}
|
||||
<span class="featured-card__section">{{ .LinkTitle }}</span>
|
||||
{{- end }}
|
||||
{{- with $page.Date }}
|
||||
<time datetime="{{ . | time.Format "2006-01-02" }}">{{ . | time.Format ":date_long" }}</time>
|
||||
{{- end }}
|
||||
</div>
|
||||
<h3 class="featured-card__title"><a href="{{ $page.RelPermalink }}">{{ $page.Title }}</a></h3>
|
||||
{{- with $page.Summary }}
|
||||
<p class="featured-card__summary">{{ . | plainify }}</p>
|
||||
{{- end }}
|
||||
<a class="featured-card__cta" href="{{ $page.RelPermalink }}">Lire l’article</a>
|
||||
</div>
|
||||
</article>
|
||||
Reference in New Issue
Block a user