我可以在Jekyll液体过滤器中使用前置物吗?

我可以在Jekyll液体过滤器中使用前置物吗?,jekyll,liquid,Jekyll,Liquid,我正在尝试创建一个相关的帖子部分。我以前使用过循环和条件来实现这一点,但我想要一种更高效、更干净的方法。我使用include变量来获得类似的结果,但无论出于何种原因,如果我试图使用帖子的前端内容,我都会得到一个空结果。例如: --- categories: - Featured --- {% assign featured-posts = site.posts | where: "categories", page.categories %} 其中过滤器在字符串或数组中查找字符串。 此处为

我正在尝试创建一个相关的帖子部分。我以前使用过循环和条件来实现这一点,但我想要一种更高效、更干净的方法。我使用include变量来获得类似的结果,但无论出于何种原因,如果我试图使用帖子的前端内容,我都会得到一个空结果。例如:

---
categories:
- Featured
---

{% assign featured-posts = site.posts | where: "categories", page.categories %} 
其中
过滤器在
字符串
数组
中查找
字符串
。 此处为
page.categories
是要在
数组中查找的
数组。这将返回一个空数组

我的最短途径,以获得相关的职位,至少有一个共同的类别

{% assign related-posts = "" | split: "" %}
{% for c in page.categories %}
  {% assign related-posts = related-posts | concat: site.categories[c] | uniq %}
{% endfor %}
{% assign related-posts = "" | split: "" %}
{% for c in page.categories %}
  {% assign related-posts = related-posts | concat: site.categories[c] | uniq %}
{% endfor %}