Jekyll`where_exp`filter with";包括「;表达

Jekyll`where_exp`filter with";包括「;表达,jekyll,liquid,Jekyll,Liquid,我正在为我的Jekyll网站的作者创建一个页面。在这一页上,我想展示这位作者写的所有文章 我的帖子是这样的: title: "Some title" authors: [author1, author2] 为了保存作者列表,我使用了集合 一个作者看起来是这样的: short: author1 name: "Author 1 Full Name" 现在,对于author1我想找到这位作者的所有文章。我试图使用where\u exp来实现: {% assi

我正在为我的Jekyll网站的作者创建一个页面。在这一页上,我想展示这位作者写的所有文章

我的帖子是这样的:

title: "Some title"
authors: [author1, author2]
为了保存作者列表,我使用了集合

一个作者看起来是这样的:

short: author1
name: "Author 1 Full Name"
现在,对于
author1
我想找到这位作者的所有文章。我试图使用
where\u exp
来实现:

{% assign articles = site.posts | where_exp: "authors", "authors contains page.short" %}
在本例中,
page.short
包含
author1


但是列表
文章
是空的。您知道可能是什么问题吗?

如果您的筛选器中存在语法问题,您可以参考其使用方式

你可以看到它被用作

{{site.members}其中_exp:“item”,“item.projects包含'foo'}
但是在您的尝试中,您没有定义
查询应该包含的项的哪个字段

在代码中

where_exp:"item", "item.projects contains 'foo'"
我们确实从数组中定义了一个
,然后我们希望这个
有一个字段
项目
;我们只想要一个包含项目
foo

当在代码中时

where_exp: "authors", "authors contains page.short" 
您是说
项目
实际上被称为
作者
,您希望项目本身包含
页面。short

更正确的方法是:

site.posts | where_exp: "post", "post.authors contains page.short"
因为数组
site.posts
中的项目实际上是
posts
,所以其中的一个项目是
post


然后,在一篇文章中,您希望一个字段
authors
,因此
post.authors
包含一个特定的字符串。

,谢谢您的解释。现在更清楚了