Filter using array variable

Hi All,

I have a blog section in which the articles md files have categories assigned to them.

I was hoping that there would be a way to filter by using the last segment of the url but discovered that the docs only reference hard coded options. I went over this other posts method http://npf.io/2014/08/making-it-a-series/ but had equally no luck with it the call.

My categories are listed in an array as follows in the article md file
categories = [ “Support”, “Events” ]

When I visit /blog/category/events/ I am looking to list out the information of all articles that have events in the categories array. The method I am using is below but I can’t seem to get it working, I have varied the way the call is made but still no joy.

{{ range (where .Site.Pages “.Params.categories” “in” “Events”) }}
{{ .Title }}
{{ end }}

The docs related to this function only reference a single variable and an reference to arrays just suggest “in” but I am stumped on this one.

Cheers
C

For now you’ll need to put an if statement inside the range.

{{ range .Site.Pages }}
  {{ if in "Events" .Params.categories }}
    {{ .Title }}
  {{ end }}
{{ end }}

What you really need is this feature: