Query to filter page by current page's path in page field's array

This works:

query: site.find("recipes").children.filterBy('Categories', page)

Where the content file includes

Categories: recipe-categories/desserts

But when the content is an array the same filter does not work:

Categories: recipe-categories/desserts, recipe-categories/holidays

So I tried updating the filter to this:

 query: site.find("recipes").children.filterBy(page, 'in', 'Categories', ',')

But that doesn’t work.

For reference, here’s my full field (note that I’m using the pagesdisplay plugin in order to enable filtering pages):

recipes_in_category:
  headline: Recipes in Category
  template: recipes-entry
  type: pagesdisplay
  query: site.find("recipes").children.filterBy(page, 'in', 'Categories', ',')

Any ideas?

I don’t think that’s how the "in" filter works, it expects an array and you’re giving it the string 'Description'. Also that last ',' argument would be applied to the first argument (which in your case is page).

So it’s not directly related to the query syntax, but much more to how the filterBy method works, meaning that also calling it directly in php, like:

site()->find("recipes")->children->filterBy($page, 'in', 'Categories', ',')

wouldn’t work.

I think you might try something like:

query: site.find("recipes").children.filterBy('Categories', '==', page, ',')

or just

query: site.find("recipes").children.filterBy('Categories', page, ',')