Generating a json file with resources.ExecuteAsTemplate

Hi,
during generation of a json file with this script:

{{ $searchData := resources.Get "list.json" | resources.ExecuteAsTemplate "search-data.json" . }}
and this code on list.json:

[
    {{ $pages := where .Site.Pages "Kind" "in" (slice "page" "post") }}
    {{ $pages = where $pages "Content" "not in" (slice nil "") }}
    {{ range $index, $page := $pages }}
        {{ if ne $index 0 }},{{ end }}
            {
                "id": {{ $index }},
                "href": "{{ $page.Permalink }}",
                "title": {{ $page.Title | jsonify }},
                "section": "{{ $page.Section }}",
                "date" : {{ $page.Date.Format "2006.01.02" | jsonify }},
                "body": {{ $page.Plain | jsonify }}
            }
    {{ end }}
]

i obtain a search-data.json containing only two brackets with nothing inside.

On config I corectly configured output:

[outputs]
  home = ["HTML", "JSON", "RSS", "AMP"]

I dont undestand what is occurring to my searching code that previusly works.

Git repo: GitHub - antedoro/arberia-demo: Arberia Theme Demo Site

Have you any suggestion?

2 things to consider in the above:

  1. resources.ExecuteAsTemplate is not connected to the outputs configuration.
  2. I would recommend that you build your data structure first (a slice) and then use jsonify on that structure.

E.g.

{{ $items := slice }}
 {{ range $index, $page := $pages }}
{{ $items = $items | append (dict "href" .Permalink) }}
{{ end }}
{{ $items | jsonify }}
{{ end }}