Skip to content

Commit

Permalink
Improved homepage layout
Browse files Browse the repository at this point in the history
  • Loading branch information
ErisDS committed Jul 20, 2023
1 parent 04be46d commit 61a5d92
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 7 deletions.
1 change: 1 addition & 0 deletions assets/css/screen.css
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,7 @@ production stylesheet in assets/built/screen.css
text-decoration: none;
}


.post-feed .no-image .post-card-content-link {
padding: 0;
}
Expand Down
14 changes: 7 additions & 7 deletions homepage.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,29 @@
<main id="site-main" class="site-main outer">
<div class="inner posts">

<div class="post-feed">
<h3>Featured</h3>
<div class="post-feed">
{{#collection "featured" limit="3"}}
<h3 class="post-card-large">Featured</h3>
{{#foreach posts}}
{{> "post-card"}}
{{> "collection-card"}}
{{/foreach}}
{{/collection}}
</div>

<div class="post-feed">
<h3>From the Podcast</h3>
{{#collection "podcast" limit="3"}}
<h3 class="post-card-large">From the Podcast</h3>
{{#foreach posts}}
{{> "post-card"}}
{{> "collection-card"}}
{{/foreach}}
{{/collection}}
</div>

<div class="post-feed">
<h3>Latest</h3>
{{#collection "latest" limit="3"}}
<h3 class="post-card-large">Latest</h3>
{{#foreach posts}}
{{> "post-card"}}
{{> "collection-card"}}
{{/foreach}}
{{/collection}}
</div>
Expand Down
75 changes: 75 additions & 0 deletions partials/collection-card.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{{!-- This is a partial file used to generate a post "card"
which templates loop over to generate a list of posts. --}}

<article class="post-card {{post_class}}{{#match @custom.feed_layout "Classic"}}{{#is "home"}}dynamic{{/is}}{{/match}}{{#match @custom.feed_layout "Grid"}} keep-ratio{{/match}}{{#match @custom.feed_layout "List"}}{{#is "home, paged"}} post-card-large{{/is}}{{/match}}{{#unless access}} post-access-{{visibility}}{{/unless}}">

{{#if feature_image}}
<a class="post-card-image-link" href="{{url}}">

{{!-- This is a responsive image, it loads different sizes depending on device
https://medium.freecodecamp.org/a-guide-to-responsive-images-with-ready-to-use-templates-c400bd65c433 --}}
<img class="post-card-image"
srcset="{{img_url feature_image size="s"}} 300w,
{{img_url feature_image size="m"}} 600w,
{{img_url feature_image size="l"}} 1000w,
{{img_url feature_image size="xl"}} 2000w"
sizes="(max-width: 1000px) 400px, 800px"
src="{{img_url feature_image size="m"}}"
alt="{{#if feature_image_alt}}{{feature_image_alt}}{{else}}{{title}}{{/if}}"
loading="lazy"
/>

{{#unless access}}
{{^has visibility="public"}}
<div class="post-card-access">
{{> "icons/lock"}}
{{#has visibility="members"}}
Members only
{{else}}
Paid-members only
{{/has}}
</div>
{{/has}}
{{/unless}}

</a>
{{/if}}

<div class="post-card-content">

<a class="post-card-content-link" href="{{url}}">
<header class="post-card-header">
<div class="post-card-tags">
{{#primary_tag}}
<span class="post-card-primary-tag">{{name}}</span>
{{/primary_tag}}
</div>
<h2 class="post-card-title">
{{#unless access}}
{{^has visibility="public"}}
{{#unless feature_image}}
{{> "icons/lock"}}
{{/unless}}
{{/has}}
{{/unless}}
{{title}}
</h2>
</header>
{{#if excerpt}}
<div class="post-card-excerpt">{{excerpt}}</div>
{{/if}}
</a>

<footer class="post-card-meta">
<time class="post-card-meta-date" datetime="{{date format="YYYY-MM-DD"}}">{{date}}</time>
{{#if reading_time}}
<span class="post-card-meta-length">{{reading_time}}</span>
{{/if}}
{{#if @site.comments_enabled}}
{{comment_count}}
{{/if}}
</footer>

</div>

</article>

0 comments on commit 61a5d92

Please sign in to comment.