Hi, so I had been generating a json file that ended here http://localhost:1313/posts/index.json
and it was accomplished by having a file content/posts/_index.md
with outputs = ["HTML", "RSS", "JSON"]
and layouts/_defaults/section.json
containing:
{{- $.Scratch.Add "index" slice -}}
{{- range (where .Site.RegularPages "Type" "posts") -}}
{{- $.Scratch.Add "index" (dict "title" .Title "category" .Params.post_categories "tags" .Params.tags "content" .Plain "permalink" .Permalink "url" .URL "image" .Params.featured_image "author" .Params.author ) -}}
{{- end -}}
{{- $.Scratch.Get "index" | jsonify -}}
and this would print all the posts in /content/posts
. Exactly what I want. However I’m using Forestry to manage the content and this /content/posts/_index.md
shows up in the content list. If anyone accidentally or otherwise opens this it will end up autosaving and overwriting the file killing the json generation. I’m definitely doing something weird here because I don’t quite understand how sections and generating json works. I’ve tried adding [outputs] posts = ["HTML", "RSS", "JSON"]
(and other names replacing posts, like section and page) to the config.toml. None of these seem to work. Please help me get my heard around this! I’ve tried to read the docs and do not find them to be clear about this.
Edit: I thought I had solved this but I did not. I can’t seem to understand how this works.