在我的Jekyll网站上,我有一个概览页面,其中我列出了我的最后10个博客文章。
但是,我也为我的一些博客文章分配了一个标签exclude,而那些我不想显示。这是可行的,但我没有得到最后10个博客文章,而是10个减去exclude博客文章的数量。
如下所示:
---
layout: page
title: "Last posts"
permalink: /last/
---
### Last posts
{% for post in site.posts limit:10 %}
{% unless post.category == "exclude"%}
* {{ post.date | date_to_string }} » [ {{ post.title }} ]({{ post.url }})
{% endunless %}
{% endfor %}我怎么能总是显示最后10个非exclude博客文章?
发布于 2017-08-14 11:14:01
为了显示最后10篇不排除的博客文章:
exclude标记的posts数组。
{%赋值非排他性帖子=‘\ { % } {% site.posts %} {除非post.category ==“排除”%} {%指定非排他性帖子=非排他性帖子+push: post %} {% endfor %} {% endfor%}%%}https://stackoverflow.com/questions/45668953
复制相似问题