Skip to content

Commit

Permalink
feat: support featured image
Browse files Browse the repository at this point in the history
- adds featured image to archive page
- adds featured image to top of post
  • Loading branch information
rise-erpelding committed Oct 24, 2023
1 parent fda4aa5 commit caeb1b7
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 5 deletions.
6 changes: 6 additions & 0 deletions src/php/views/page.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
{% block content %}

<div class="obj-width-limiter">
<img
src="{{ post.thumbnail.src|resize(960) }}"
{% if post.thumbnail.alt and post.thumbnail.alt|length > 0 %}
alt="{{ post.thumbnail.alt }}"
{% endif %}
/>
{{ post.content }}
</div>

Expand Down
21 changes: 16 additions & 5 deletions src/php/views/partials/content-single.twig
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
<article id="post-{{ post.id }}">
<h2>
{{ post.title }}
</h2>
<article id="post-{{ post.id }}" class="post-preview">
{% if post.thumbnail %}
<img
src="{{ post.thumbnail.src('thumbnail') }}"
class="post-preview__featured-image"
{% if post.thumbnail.alt and post.thumbnail.alt|length > 0 %}
alt="{{ post.thumbnail.alt }}"
{% endif %}
/>
{% endif %}
<div>
{{ post.preview }}
<h2 class="post-preview__title">
{{ post.title }}
</h2>
<div>
{{ post.preview }}
</div>
</div>
</article>
1 change: 1 addition & 0 deletions src/scss/base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
// and our UI components are often composed of Objects and Components
@import 'components/main-nav';
@import 'components/pagination';
@import 'components/post-preview';
@import 'components/primary-sidebar';
@import 'components/post-body';
@import 'components/skip-to-content';
Expand Down
20 changes: 20 additions & 0 deletions src/scss/components/_post-preview.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.post-preview {
margin-bottom: 1.5rem;
min-height: 9.375rem; // 150px

@media (min-width: 50rem) {
display: flex;
column-gap: 1.5rem;
}

&__title {
margin: 0 0 1rem;
}

&__featured-image {
max-height: 9.375rem; // 150px
max-width: 9.375rem; // 150px
width: auto;
height: auto;
}
}

0 comments on commit caeb1b7

Please sign in to comment.