Introduction du nouveau thème
This commit is contained in:
51
themes/42/layouts/_partials/card.html
Normal file
51
themes/42/layouts/_partials/card.html
Normal file
@@ -0,0 +1,51 @@
|
||||
<a href="{{ .RelPermalink }}" class="card panel panel-hero">
|
||||
{{ $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 := .Fill "450x220" -}}
|
||||
<div class="card-image" style="background-image: url({{ $resized.RelPermalink }});"></div>
|
||||
{{ end -}}
|
||||
{{ else }}<div class="card-image"></div>
|
||||
{{ end -}}
|
||||
<div class="card-content">
|
||||
<h3>{{ .Title }}</h3>
|
||||
{{- if not $page.IsSection -}}
|
||||
{{- with $page.Date -}}
|
||||
<time datetime="{{ . }}">{{ . | time.Format ":date_long" }}</time>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
<div class="card-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>
|
||||
Reference in New Issue
Block a user