mirror of
https://github.com/GenZmeY/casper-i18n.git
synced 2024-11-10 02:28:02 +00:00
🐛 Only show related posts widget if there are posts available (#332)
no issue - use a block param and if combo to add a guard to the get helper - this ensures that the widget is only displayed if there is content available to display
This commit is contained in:
parent
35e91ecee9
commit
4b66223bb3
6
post.hbs
6
post.hbs
@ -102,7 +102,8 @@ into the {body} of the default.hbs template --}}
|
||||
<div class="inner">
|
||||
<div class="read-next-feed">
|
||||
|
||||
{{#get "posts" filter="tags:{{tags.[0].slug}}+id:-{{id}}" limit="3"}}
|
||||
{{#get "posts" filter="tags:{{tags.[0].slug}}+id:-{{id}}" limit="3" as |related_posts|}}
|
||||
{{#if related_posts}}
|
||||
<article class="read-next-card"
|
||||
{{#if ../tags.[0].feature_image}}
|
||||
style="background-image: url({{../tags.[0].feature_image}})"
|
||||
@ -118,7 +119,7 @@ into the {body} of the default.hbs template --}}
|
||||
<div class="read-next-divider">{{> "icons/infinity"}}</div>
|
||||
<div class="read-next-card-content">
|
||||
<ul>
|
||||
{{#foreach posts}}
|
||||
{{#foreach related_posts}}
|
||||
<li><a href="{{url}}">{{title}}</a></li>
|
||||
{{/foreach}}
|
||||
</ul>
|
||||
@ -127,6 +128,7 @@ into the {body} of the default.hbs template --}}
|
||||
<a href="{{@blog.url}}/tag/{{../tags.[0].slug}}/">{{plural meta.pagination.total empty='No posts' singular='% post' plural='See all % posts'}} →</a>
|
||||
</footer>
|
||||
</article>
|
||||
{{/if}}
|
||||
{{/get}}
|
||||
|
||||
{{!-- If there's a next post, display it using the same markup included from - partials/post-card.hbs --}}
|
||||
|
Loading…
Reference in New Issue
Block a user