首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Jekyll截断博客文章的数量,但条件是不包括一些

Jekyll截断博客文章的数量,但条件是不包括一些
EN

Stack Overflow用户
提问于 2017-08-14 06:55:27
回答 1查看 67关注 0票数 1

在我的Jekyll网站上,我有一个概览页面,其中我列出了我的最后10个博客文章。

但是,我也为我的一些博客文章分配了一个标签exclude,而那些我不想显示。这是可行的,但我没有得到最后10个博客文章,而是10个减去exclude博客文章的数量。

如下所示:

代码语言:javascript
复制
---
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博客文章?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-08-14 11:14:01

为了显示最后10篇不排除的博客文章:

  1. 创建一个不包含exclude标记的posts数组。 {%赋值非排他性帖子=‘\ { % } {% site.posts %} {除非post.category ==“排除”%} {%指定非排他性帖子=非排他性帖子+push: post %} {% endfor %} {% endfor%}%%}
  2. 显示10个最近的帖子
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45668953

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档