Dynamic page list with where & intersect

I try to make a list where arg1 = arg2 to display.
Basically I have a front matter with a param arg1 and a file data.json with arg2.
I’ve tried :

{{ $city := .Params.city }}
      {{ range .Site.Data.petiteannonce }}
      {{ $cityName := .Params.cityName }}
      {{ $is_same_city := intersect $city $cityName | len | lt 0 }}
        {{ if $is_same_city }}
          {{ $cityName }}
        {{ end }}
      {{ end }}

or i’ve tried

{{ $city := .Params.city }}
{{ $cityName := where .Site.Data.petiteannonce ".cityName" ".Params.city" }}
{{ $filtered := $city | intersect $cityName }}
{{ range $filtered }}
{{ end }}

--> error calling intersect: can't iterate over string

Thanks for your help … and the new doc :slight_smile:

Ok the answer was :slight_smile:

{{ $city := .Params.city }}
    {{ range .Site.Data.petiteannonce }}
    {{ $cityName := .cityName }}
      {{ if eq $city $cityName}}
       blabla
      {{ end }}
    {{end}}
1 Like