Jekyll - 无法按日期反转排序
Jekyll - Can't reverse sort by date
我正在尝试对最近的 3 篇文章进行排序,'featured' 只在我的博客上发布,但是对于我目前使用的循环不允许我对集合进行排序以首先显示最新的帖子。
我下面的内容输出了我博客上的三篇最新帖子,但忽略了 where_exp 并同时显示精选和非精选帖子。
如果我在按日期排序后删除 'reverse' 过滤器,它只会对特色帖子进行排序,但会将它们从旧到新排序。我已经尝试重新分配 featured-posts 变量以在 for 循环之前再次按反向日期排序,但它不起作用。
到目前为止,我所做的一切都无法让我在我的网站上显示三个最新的精选帖子,我希望有人能告诉我哪里出错了..
Post 前题:
---
post_date: 2017-08-14 00:00:00
featured: true
---
页面 For 循环:
{% assign sorted-posts = site.posts | sort: 'post_date' | reverse %}
{% assign featured-posts = sorted-posts | where_exp:"post","post.featured" %}
{% for post in featured-posts limit:3 %}
<h2><a href="{{ post.url }}">{{ post.title | truncate: 58 }}</a></h2>
{% endfor %}
输出:
Three most recent posts on the website regardless of whether they're 'featured' or not.
提前致谢
通过升级 Jekyll 解决。我是运行版本3.0.0,升级到3.5.2,问题已经解决
我正在尝试对最近的 3 篇文章进行排序,'featured' 只在我的博客上发布,但是对于我目前使用的循环不允许我对集合进行排序以首先显示最新的帖子。
我下面的内容输出了我博客上的三篇最新帖子,但忽略了 where_exp 并同时显示精选和非精选帖子。 如果我在按日期排序后删除 'reverse' 过滤器,它只会对特色帖子进行排序,但会将它们从旧到新排序。我已经尝试重新分配 featured-posts 变量以在 for 循环之前再次按反向日期排序,但它不起作用。
到目前为止,我所做的一切都无法让我在我的网站上显示三个最新的精选帖子,我希望有人能告诉我哪里出错了..
Post 前题:
---
post_date: 2017-08-14 00:00:00
featured: true
---
页面 For 循环:
{% assign sorted-posts = site.posts | sort: 'post_date' | reverse %}
{% assign featured-posts = sorted-posts | where_exp:"post","post.featured" %}
{% for post in featured-posts limit:3 %}
<h2><a href="{{ post.url }}">{{ post.title | truncate: 58 }}</a></h2>
{% endfor %}
输出:
Three most recent posts on the website regardless of whether they're 'featured' or not.
提前致谢
通过升级 Jekyll 解决。我是运行版本3.0.0,升级到3.5.2,问题已经解决