List posts filtered by directory

Given the following structure of the content folder:

- blog
  ├─ 2019
  ├─ myoldposts
  |  ├─ 2008
  |  └─ 2009
  └─ shares
     ├─ 2019
     └─ migrated
        ├─ 2014
        └─ 2015

How can I list pages only from shares plus subdirectories?

I can use

range (where .Pages ".File.Dir" "in" "blog/shares/migrated/2014/")

to filter for the lowest subdirectory.

But when I try to go one level up it doesn’t work anymore:

range (where .Pages ".File.Dir" "in" "blog/shares/migrated/")

Using comparators like ge doesn’t work either.

Is there no function that checks for a substring?

Similar problems that got solved in other ways:

Have a look also in this thread:

Merci. As far as I can see that post tackles a similar issue. Difference seems to be that I don’t want posts grouped by subfolder. I want them all listed in the blog but also have a page where I list a subset.

So the question is: How do I get an array of all the posts stored below a specific folder.

Another thing I’ve played around with is findRE. Unfortunately I can’t get it to work in where either:

Because findRE is not a valid operator in where I can’t do:

{{ $posts := where .Pages ".FileDir" "findRE" $path }}

And this doesn’t work because “.FileDir” is treated as a string:

{{ $posts := where .Pages (len (findRE $path ".FileDir")) "gt" 0 }}