Skip to content

Commit d3bbd15

Browse files
author
Daniel Precioso
committed
Refactor featured image styles for entry pages to ensure consistent sizing and alignment
1 parent d324a18 commit d3bbd15

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

layouts/_default/single.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
{{ $isProjectPage := and .IsPage (or (eq .Type "industry") (eq .Type "research")) }}
1313
{{ $isWideSinglePage := and .IsPage (or (eq .Type "industry") (eq .Type "research") (eq .Type "event") (eq .Type "post")) }}
1414
{{ $isPostPage := and .IsPage (eq .Type "post") }}
15+
{{ $isEntryFeaturedConstrained := $isWideSinglePage }}
1516

1617
<div class="mx-auto flex {{ if $isWideSinglePage }}max-w-screen-2xl{{ else }}max-w-screen-xl{{ end }}">
1718
{{ if not $isWideSinglePage }}
@@ -153,9 +154,9 @@ <h1 class="mt-2 text-4xl font-bold tracking-tight text-center text-slate-900 dar
153154
{{end}}
154155
{{ if ne $image.MediaType.SubType "gif" }}{{ $image = $image.Process "webp" }}{{ end }}
155156
{{/* Featured image */}}
156-
<div class="article-header {{$image_container}} featured-image-wrapper mt-4 mb-16 mx-auto {{ if $isPostPage }}post-featured-image-wrapper{{ end }}">
157+
<div class="article-header {{$image_container}} featured-image-wrapper mt-4 mb-16 mx-auto {{ if $isEntryFeaturedConstrained }}entry-featured-image-wrapper{{ end }} {{ if $isPostPage }}post-featured-image-wrapper{{ end }}">
157158
<div style="position: relative">
158-
<img src="{{ $image.RelPermalink }}" width="{{ $image.Width }}" height="{{ $image.Height }}" alt="{{ with $.Params.image.alt_text }}{{.}}{{ end }}" class="featured-image {{ if $isPostPage }}post-featured-image{{ end }}">
159+
<img src="{{ $image.RelPermalink }}" width="{{ $image.Width }}" height="{{ $image.Height }}" alt="{{ with $.Params.image.alt_text }}{{.}}{{ end }}" class="featured-image {{ if $isEntryFeaturedConstrained }}entry-featured-image{{ end }} {{ if $isPostPage }}post-featured-image{{ end }}">
159160
{{ with $.Params.image.caption }}<span class="article-header-caption">{{ . | markdownify | emojify }}</span>{{ end }}
160161
</div>
161162
</div>

layouts/partials/components/headers/navbar.html

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,19 @@
3939
}
4040
{{ end }}
4141

42-
/* Post pages: keep featured images visually smaller than body content width. */
42+
/* Single entry pages: keep featured images visually smaller than body content width. */
43+
.page-body .entry-featured-image-wrapper {
44+
text-align: center;
45+
}
46+
47+
.page-body .entry-featured-image {
48+
width: min(100%, 42rem);
49+
height: auto;
50+
margin-left: auto;
51+
margin-right: auto;
52+
}
53+
54+
/* Post pages use a slightly tighter cap. */
4355
.page-body .post-featured-image-wrapper {
4456
text-align: center;
4557
}

0 commit comments

Comments
 (0)