如何在 jekyll 中为 categories.html 使用分页为特定类别的帖子编写逻辑?
how in jekyll, for categories.html write a logic for posts in specific category using pagination?
我有带 post.thumb 和不带 post.thumb 的帖子,我只想在下面的结构中显示带 post.thumb 的帖子,而不对帖子使用限制和偏移量。
我有一个 categories.html 具有下一个结构:
<section class="type-one">
{% for post in pagination.posts limit:1 Offset:0 %}
<div class="col-md-7">
{% include FirstPostInCategoryNews.html %}
</div>
{% endfor %}
<div class="col-md-5 two_items_incide">
{% for post in pagination.posts limit:2 Offset:1 %}
{% include TwoPostsAfterFirstPostInCatNews.html%}
{% endfor %}
</div>
</section>
<section class="others_posts_in_cat_news">
<div class="col-md-7">
{% for post in pagination.posts limit:7 Offset:3 %}
{% include OtherPostsInCategoryNews.html %}
{% endfor %}
</div>
</section>
为了更好地理解我想要的是
这是我的解决方案,在 JoostS
的帮助下
首先,我添加到我的所有帖子中,其中包含 post.thumb 下一个标签 (bg)
---
layout: post
thumb: "path/to/image/"
bg: "yes"
---
下一步是我用 bg: "yes" 循环浏览我所有的帖子,使用过滤器。
所以最后我做了什么:
<section class="type-one">
<div class="row">
{% assign posts = paginator.posts | where: "bg", "yes" %} // creating var//
<div class="col-md-7">
{% for post in posts limit: 1 %}
{% include FirstPostInCategoryNews.html %}
{% endfor %}
</div>
<div class="col-md-5 item-title-white">
{% for post in posts limit: 2 offset: 1 %}
{% include TwoPostsAfterFirstPostInCatNews.html %}
{% endfor %}
</div>
</div>
</section>
第二部分:
<section class="others_posts_in_cat_news">
<div class="col-md-7">
{% assign posts = paginator.posts | where: "bg", "yes" %}
{% for post in posts limit: 4 offset: 3 %}
{% include OtherPostsInCategoryNews.html %}
{% endfor %}
</div>
</section>
如果有人不明白,请随时提问!
我有带 post.thumb 和不带 post.thumb 的帖子,我只想在下面的结构中显示带 post.thumb 的帖子,而不对帖子使用限制和偏移量。
我有一个 categories.html 具有下一个结构:
<section class="type-one">
{% for post in pagination.posts limit:1 Offset:0 %}
<div class="col-md-7">
{% include FirstPostInCategoryNews.html %}
</div>
{% endfor %}
<div class="col-md-5 two_items_incide">
{% for post in pagination.posts limit:2 Offset:1 %}
{% include TwoPostsAfterFirstPostInCatNews.html%}
{% endfor %}
</div>
</section>
<section class="others_posts_in_cat_news">
<div class="col-md-7">
{% for post in pagination.posts limit:7 Offset:3 %}
{% include OtherPostsInCategoryNews.html %}
{% endfor %}
</div>
</section>
为了更好地理解我想要的是
这是我的解决方案,在 JoostS
的帮助下首先,我添加到我的所有帖子中,其中包含 post.thumb 下一个标签 (bg)
---
layout: post
thumb: "path/to/image/"
bg: "yes"
---
下一步是我用 bg: "yes" 循环浏览我所有的帖子,使用过滤器。
所以最后我做了什么:
<section class="type-one">
<div class="row">
{% assign posts = paginator.posts | where: "bg", "yes" %} // creating var//
<div class="col-md-7">
{% for post in posts limit: 1 %}
{% include FirstPostInCategoryNews.html %}
{% endfor %}
</div>
<div class="col-md-5 item-title-white">
{% for post in posts limit: 2 offset: 1 %}
{% include TwoPostsAfterFirstPostInCatNews.html %}
{% endfor %}
</div>
</div>
</section>
第二部分:
<section class="others_posts_in_cat_news">
<div class="col-md-7">
{% assign posts = paginator.posts | where: "bg", "yes" %}
{% for post in posts limit: 4 offset: 3 %}
{% include OtherPostsInCategoryNews.html %}
{% endfor %}
</div>
</section>
如果有人不明白,请随时提问!