mirror of
https://github.com/Vimux/Binario.git
synced 2024-11-22 05:58:33 +00:00
efb650245f
WARNING: UPGRADE HUGO TO VERSION 0.54.0 OR LATER * post_thumbnail -> post_featured * Add url, alt, caption and credit params for featured * Add previewOnly param * Add styles for featured * Add fallback for thumbnail.* * Add "Featured Images" page * Show caption & credit on single pages only * Update README: add featured image guide * Bump Hugo min version because `reflect.IsMap` [0.38 -> 0.54.0]
41 lines
No EOL
1.3 KiB
HTML
41 lines
No EOL
1.3 KiB
HTML
{{- with .page.Resources.ByType "image" }}
|
|
{{- $link := $.link -}}
|
|
{{- $IsSingle := $.IsSingle -}}
|
|
{{- $match := $.page.Params.featured -}}
|
|
{{- $featuredMap := "" -}}
|
|
|
|
{{- $IsMap := reflect.IsMap $match -}}
|
|
{{- if $IsMap }}
|
|
{{- $featuredMap = $match -}}
|
|
{{- $match = $match.url -}}
|
|
{{- end }}
|
|
|
|
{{- $featured := .GetMatch ($match | default "{featured.*,thumbnail.*}") -}}
|
|
{{ if and $featured (not (and $IsSingle ($.page.Param "featured.previewOnly"))) }}
|
|
<figure class="post__featured featured">
|
|
{{- with $link }}<a class="featured__link" href="{{ . }}">{{ end }}
|
|
<img class="featured__img" src="{{ $featured.RelPermalink }}" alt="
|
|
{{- with $featuredMap -}}
|
|
{{- .alt | default $featured.Title -}}
|
|
{{- else -}}
|
|
{{- $featured.Title -}}
|
|
{{- end -}}
|
|
"/>
|
|
{{- with $link }}</a>{{ end }}
|
|
{{- with $IsSingle }}
|
|
{{- with $featuredMap }}
|
|
{{- if or .caption .credit }}
|
|
<figcaption class="featured__figcaption">
|
|
{{- with .caption }}
|
|
<div class="featured__caption">{{ . | markdownify }}</div>
|
|
{{- end }}
|
|
{{- with .credit }}
|
|
<cite class="featured__credit">{{ . | markdownify }}</cite>
|
|
{{- end }}
|
|
</figcaption>
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|
|
</figure>
|
|
{{- end }}
|
|
{{- end }} |