Replace "hidden" check in Liquid with where_exp

This commit is contained in:
iBug
2024-05-05 03:18:27 +08:00
parent bde92b6d4a
commit 6165d896a0
7 changed files with 16 additions and 23 deletions

View File

@@ -1,14 +1,10 @@
{% assign posts = include.posts | where_exp: "post", "post.hidden != true" %}
<div class="page__related">
{% include before-related.html %}
<h2 class="page__related-title">{{ site.data.ui-text[site.locale].related_label | default: "You May Also Enjoy" }}</h2>
<div class="grid__wrapper">
{% assign count = 0 %}
{% assign limit = include.limit | default: 4 %}
{% for post in include.posts %}
{% if post.hidden %}{% continue %}{% endif %}
{% for post in posts limit:4 %}
{% if post.id == page.id %}{% continue %}{% endif %}
{% if count >= limit %}{% break %}{% endif %}
{% assign count = count | plus: 1 %}
{% include archive-single.html type="grid" %}
{% endfor %}
</div>