How to use 'not found' behaviour with a front matter array?


#1

In my front matter I specify the related content files like this:

related = ["article 1", "article 2"]

I then generate a list with the related articles like this:

{{ $sectionArticles := where $.Site.RegularPages "Section" .Page.Section }}
{{ $relatedContent := where $sectionArticles "Title" "in" .Page.Params.related }}

But how can I generate a list of page titles that were included in the related front matter, but that were not found in the .Site.RegularPages array?


I looked at the functions doc, but intersect returns an array with common elements (I’m looking for the non-matching), and I couldn’t get not in to work (understandably so):

{{ $notFound := where .Page.Params.related "not in" $sectionArticles }}

error calling where: not in is neither a struct field, a method nor a map element of type string.

This also doesn’t work:

{{ $relatedContent := where $sectionArticles "Title" "not in" .Page.Params.related }}

Because it returns a list of all pages, whereas I’m only interested in the page titles that occurred in related but weren’t found in .Site.RegularPages.

Any ideas or suggestions? Thanks!