Jekyll 杰基尔。如何按类别过滤除当前帖子外的最近帖子?
我想在一个页面上按类别获取最后3篇文章,除了此过滤器中的当前页面 我的代码不起作用:Jekyll 杰基尔。如何按类别过滤除当前帖子外的最近帖子?,jekyll,liquid,jekyll-extensions,Jekyll,Liquid,Jekyll Extensions,我想在一个页面上按类别获取最后3篇文章,除了此过滤器中的当前页面 我的代码不起作用: {% for cat in page.categories[0] %} {% for post in site.categories[cat] limit: 3 %} {% if post.title == page.title %} {% break %} {% endif %} <div class="item">
{% for cat in page.categories[0] %}
{% for post in site.categories[cat] limit: 3 %}
{% if post.title == page.title %}
{% break %}
{% endif %}
<div class="item">
<a href="{{ post.url | relative_url }}">
<div class="image" style="background-image: url({{ post.image }});"></div>
<div class="item-text main">
<h1>{{ post.title }}</h1>
</div>
</a>
</div>
{% endfor %}
{% endfor %}
{%用于页面中的cat。类别[0]}
{站点中的帖子的百分比。类别[cat]限制:3%}
{%if post.title==page.title%}
{%break%}
{%endif%}
{%endfor%}
{%endfor%}
您可以替换
{%if post.title==page.title%}
{%break%}
{%endif%}
与
{%除非post.url==page.url%}
完整代码
{% for cat in page.categories[0] %}
{% for post in site.categories[cat] limit: 3 %}
{% unless post.url == page.url %}
<div class="item">
<a href="{{ post.url | relative_url }}">
<div class="image" style="background-image: url({{ post.image }});">
</div>
<div class="item-text main">
<h1>{{ post.title }}</h1>
</div>
</a>
</div>
{% endunless %}
{% endfor %}
{% endfor %}
{%用于页面中的cat。类别[0]}
{站点中的帖子的百分比。类别[cat]限制:3%}
{%除非post.url==page.url%}
{%end除非%}
{%endfor%}
{%endfor%}