Jekyll`where_exp`filter with";包括「;表达
我正在为我的Jekyll网站的作者创建一个页面。在这一页上,我想展示这位作者写的所有文章 我的帖子是这样的: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
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
包含一个特定的字符串。,谢谢您的解释。现在更清楚了