Is it possible to establish a union of more than two sets at a time?

I’m setting up video filtering and was wondering the best approach to take when combining multiple sets of pages.

When an event is logged on any checkbox, then a query would be run for all checkboxes that are :checked that returns the objects in an array.

For each object in the array, I want to create a set following this pattern:

{{ $set := where .Site.Pages "Params.{{ $TAXONOMY }}" "{{ $TERM }}" }}

The traditional use of union would result in something like the following:

{{ $set1 := where .Site.Pages "Params.taxonomy1" "exampleterm" }}

{{ $set2 := where .Site.Pages "Params.taxonomy2" "exampleterm" }}

{{ $set3 := union $set1 $set2 }}

{{ range $set3 }}

    {{ .Params.title }}

{{ end }}

But the data set could potentially include any number of sets, so union wouldn’t work for the intended use case.

Is there any way to nest where statements to essentially accomplish the same purpose?

What would this array look like? What would your page frontmatter look like?

Try something like

{{ $biglist := slice }}

{{ range $somearr }}
  {{ $set := where ... }}
  {{ $biglist = union $biglist $set }}
{{ end }}
1 Like

So sorry for forgetting to mention! Edited the original post with additional clarification. That should work though… thank you for your input!!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.