hugo-theme-bootstrap5-blog/layouts/partials/featured.html

46 lines
2.4 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{{ $dateFormat := default "Mon Jan 2, 2006" (index .Site.Params "date_format") }}
<div class="p-4 p-md-5 mb-4 text-white rounded bg-dark">
<div class="col-md-6 px-0">
<h1 class="display-4 font-italic">Title of a longer featured blog post</h1>
<p class="lead my-3">Multiple lines of text that form the lede, informing new readers quickly and efficiently about whats most interesting in this posts contents.</p>
<p class="lead mb-0"><a href="#" class="text-white fw-bold">Continue reading...</a></p>
</div>
</div>
<div class="row mb-2">
{{ range first 2 (where .Site.RegularPages "Section" "in" .Site.Params.mainSections) | shuffle }}
<div class="col-md-6">
<div class="row g-0 border rounded overflow-hidden flex-md-row mb-4 shadow-sm h-md-300 position-relative">
<div class="col p-4 d-flex flex-column position-static">
<strong class="d-inline-block mb-2 text-primary">World</strong>
<h3 class="mb-0">{{ .Title }}</h3>
<div class="mb-1 text-muted">{{ if not .PublishDate.IsZero }}<time {{ .Date.Format "2006-01-02T15:04:05Z07:00" | printf "datetime=%q" | safeHTMLAttr }}>{{ .Date.Format $dateFormat }}</time>{{ end }}</div>
<p class="card-text mb-auto">{{ substr .Description 0 110 }}</p>
<a href="{{ .Permalink }}" class="stretched-link">Continue reading</a>
</div>
<div class="col-auto d-none d-lg-block">
{{ range first 1 (.Resources.ByType "image") }}
{{/* get a local variable for the image because we will change context below */}}
{{ $image := . }}
{{/* set orientation to 1 just in case it doesnt exist in Exif */}}
{{ $orientation := 1 }}
{{ with .Exif }}
{{ $orientation = .Tags.Orientation }}
{{ if eq $orientation 8 }}
{{/* Rotate image before cropping because Hugo's "Smart" cropping crops differently if we do it at the same time as .Fill with a rotation) and use 2x dimensions to keep the thumbnail crisp */}}
{{ $RotatedImage := $image.Resize "480x600 r90" }}
<img src={{ ($RotatedImage.Fill "480x600").RelPermalink }} width="240" height="300" />
{{ else }}
<img src={{ ($image.Fill "480x600").RelPermalink }} width="240" height="300" />
{{ end }}
{{ end }}
{{ end }}
</div>
</div>
</div>
{{ end }}
</div>
{{- /* vim: set ts=2 sw=2 et: */}}