Need to set a specific page as JSON for API

Example: go here —


there’s a folder under layouts called api, so layouts/api/index.json (or something else?) should have the code to dynamically change what’s on the page, kinda like this:

{{ $incidents := where .Site.RegularPages "Params.section" "issue" }}
{{ $active := where $incidents "Params.resolved" "=" false }}

{{ $isNotice := where $active "Params.severity" "=" "notice" }}
{{ $isDisrupted := where $active "Params.severity" "=" "disrupted" }}
{{ $isDown := where $active "Params.severity" "=" "down" }}

{{ if $isDown }}
{{ else }}
{{ if $isDisrupted }}
{{ else }}
{{ if $isNotice }}
{{ else }}
{{ end }}{{ end }}{{ end }}

Essentially, it would return a JSON object based on whether or not a certain value / if statement ran.

This is really complicated and while I found this…

…it didn’t seem to help me much.

Once again, the code for what I have is here:

You need to add Output Formats into the mix, like the original blog post explains:

I suppose you just need an extra output format on the home page.

  1. don’t want to do this for the homepage

2 how specifically? this threw an error for me