show actually related posts

This commit is contained in:
⧉ infominer 2020-11-29 22:13:01 -05:00
parent 95ab0fbd79
commit e3a3e6159c

View File

@ -66,28 +66,30 @@ layout: default
{% endif %} {% endif %}
</article> </article>
{% comment %}<!-- only show related on a post page when `related: true` -->{% endcomment %} {% comment %}<!-- show posts by related tags when `related: true` -->{% endcomment %}
{% if page.id and page.related and site.related_posts.size > 0 %} {% if page.related %}
<div class="page__related"> {% assign n_posts = 0 %}
<h4 class="page__related-title">{{ site.data.ui-text[site.locale].related_label | default: "You May Also Enjoy" }}</h4> {% for post in site.posts %}
<div class="grid__wrapper"> {% if post.id == page.id %}{% continue %}{% endif %}
{% for post in site.related_posts limit:4 %} {% for this_category in page.categories %}
{% include archive-single.html type="grid" %} {% if post.categories contains this_category %}
{% endfor %} {% if n_posts == 0 %}
</div> <div class="page__related">
</div> {% if site.data.ui-text[site.locale].related_label %}
{% comment %}<!-- otherwise show recent posts if no related when `related: true` -->{% endcomment %} <h4 class="page__related-title">{{ site.data.ui-text[site.locale].related_label | default: "You May Also Enjoy" }}</h4>
{% elsif page.id and page.related %} {% endif %}
<div class="page__related"> <div class="grid__wrapper">
<h4 class="page__related-title">{{ site.data.ui-text[site.locale].related_label | default: "You May Also Enjoy" }}</h4> {% endif %}
<div class="grid__wrapper"> {% include archive-single.html type="grid" %}
{% for post in site.posts limit:4 %} {% assign n_posts = n_posts | plus: 1 %}
{% if post.id == page.id %} {% break %}
{% continue %}
{% endif %} {% endif %}
{% include archive-single.html type="grid" %} {% endfor %}
{% endfor %} {% if n_posts > 3 %}{% break %}{% endif %}
{% endfor %}
{% if n_posts > 0 %}
</div>
</div> </div>
</div> {% endif %}
{% endif %} {% endif %}
</div> </div>