Range with variable from frontmatter (Multilingual)

Hi everyone, I have a question.

I created an FAQ partial and I want to add it dynamically to any page getting an ID from frontmatter.

This is my Data structure. I like to separate the languages ​​using folders.

Captura de Tela 2022-10-05 às 13.32.02

My frontmatter is:

title: Example
slug: 'example'
faqId: 'id'

To access my data files I need to allow access in all languages ​​because my website has a multilingual mode:

{{ $data := index .Site.Data .Site.Language.Lang }}

I’m having a problem with the range, when I manually put the faqID it works.

{{ range $data.faq.faqId }}

When I try to get the frontmatter variable, for some reason it doesn’t work. I’ve seen some examples with two ranges or with, but I wanted to know the best way to do this.

{{ range $data.faq(.Params.faqId) }}

I know the structure isn’t right. This example is just to exemplify what I’m trying to do.

I preferred to create the FAQ as a date file because I don’t want to make individual pages for each FAQ and I also didn’t use taxonomy because that’s not what I want.

The index function is variadic—it accepts a variable number of arguments.

{{ index site.Data .Lang "faq" (string .Params.faqID) }}