Skip to content

Commit caeb1b7

Browse files
feat: support featured image
- adds featured image to archive page - adds featured image to top of post
1 parent fda4aa5 commit caeb1b7

File tree

4 files changed

+43
-5
lines changed

4 files changed

+43
-5
lines changed

src/php/views/page.twig

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
{% block content %}
44

55
<div class="obj-width-limiter">
6+
<img
7+
src="{{ post.thumbnail.src|resize(960) }}"
8+
{% if post.thumbnail.alt and post.thumbnail.alt|length > 0 %}
9+
alt="{{ post.thumbnail.alt }}"
10+
{% endif %}
11+
/>
612
{{ post.content }}
713
</div>
814

+16-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
1-
<article id="post-{{ post.id }}">
2-
<h2>
3-
{{ post.title }}
4-
</h2>
1+
<article id="post-{{ post.id }}" class="post-preview">
2+
{% if post.thumbnail %}
3+
<img
4+
src="{{ post.thumbnail.src('thumbnail') }}"
5+
class="post-preview__featured-image"
6+
{% if post.thumbnail.alt and post.thumbnail.alt|length > 0 %}
7+
alt="{{ post.thumbnail.alt }}"
8+
{% endif %}
9+
/>
10+
{% endif %}
511
<div>
6-
{{ post.preview }}
12+
<h2 class="post-preview__title">
13+
{{ post.title }}
14+
</h2>
15+
<div>
16+
{{ post.preview }}
17+
</div>
718
</div>
819
</article>

src/scss/base.scss

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
// and our UI components are often composed of Objects and Components
6565
@import 'components/main-nav';
6666
@import 'components/pagination';
67+
@import 'components/post-preview';
6768
@import 'components/primary-sidebar';
6869
@import 'components/post-body';
6970
@import 'components/skip-to-content';
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.post-preview {
2+
margin-bottom: 1.5rem;
3+
min-height: 9.375rem; // 150px
4+
5+
@media (min-width: 50rem) {
6+
display: flex;
7+
column-gap: 1.5rem;
8+
}
9+
10+
&__title {
11+
margin: 0 0 1rem;
12+
}
13+
14+
&__featured-image {
15+
max-height: 9.375rem; // 150px
16+
max-width: 9.375rem; // 150px
17+
width: auto;
18+
height: auto;
19+
}
20+
}

0 commit comments

Comments
 (0)