过滤器 paginator.posts

Filter paginator.posts

我 运行 香草 Jekyll (4.1.1) 系统。它在分页的索引页上显示 posts,并在两列中显示此代码:

<div class="row">
  <div class="col-md-6">
    {%- for post in paginator.posts -%}
    {% assign mod3 = forloop.index | modulo: 2 %}
    {% if mod3 != 0 %}
    {% include card_post.html post=post %}
    {%- endif -%}
    {%- endfor -%}
  </div>

  <div class="col-md-6">
    {%- for post in paginator.posts -%}
    {% assign mod3 = forloop.index | modulo: 2 %}
    {% if mod3 == 0 %}
    {% include card_post.html post=post %}
    {%- endif -%}
    {%- endfor -%}
  </div>
</div>

每个 post 都有这个 header:

  ---
  layout: blogpost
  title:  "foobar"
  publication_date: 2020-12-11
  categories:
    - car
    - whatever
  ---

在索引页上,我只想显示 post,不包括值为 bikecategories。这似乎是一件很容易做的事情,但我找不到与分页一起使用的负面过滤器。

我该如何解决这个问题?

hidden: true 告诉分页不要使用它。它并不完美,但解决了这个特定问题。

https://jekyllrb.com/docs/pagination/

Pagination does not support tags or categories. Pagination pages through every post in the posts variable unless a post has hidden: true in its front matter. It does not currently allow paging over groups of posts linked by a common tag or category. It cannot include any collection of documents because it is restricted to posts.