Issue with 'where' and nested params

I am trying to get the number of total posts by the author of the current page.

In my frontmatter I have

  name: 'Jayphen'
  img: '<href>'
  id: 12345

The logic I am using to get the number is:

{{ $author_posts := len (where (where .Site.Pages "Section" "post") "" }}

This fails with error calling where: can't evaluate an invalid value

However, when attempting to do the same comparison (just not on a nested param):

{{ $author_posts := len (where (where .Site.Pages "Section" "post") ".Params.type" .Params.type) }}

this returns an integer as expected.

Is this a bug, or am I doing something wrong?

I have run into this issue a couple of times now and have resorted to flattening my data structure in my frontmatter. This works, but I am still unclear as to whether I was doing something wrong here.

Does where simply not allow nested params?

To simplify my example:

  name: Hungary
  code: HUN
  continent: Europe
destination: Europe

This works:

  {{ range where .Site.Pages "Params.destination" "Europe" }}
    {{ .Content }}
  {{ end }}

whereas this fails with error calling where: can't evaluate an invalid value:

  {{ range where .Site.Pages "" "Europe" }}
    {{ .Content }}
  {{ end }}

What’s the output if you use where with "Params.continent"?

I don’t know how custom front matter variables deal with the indentation in the front matter. I suspect they ignore it, so indenting continent below country might simply look as a continent variable to Hugo – and not as country.continent.

There is no output with Params.continent.

If I simply echo the value inside my template it returns as it should:
{{ }} returns Europe in the template.

It is only in where that the nesting does not work.