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" }}
{"status":
{{ if $isDown }}
"down"}
{{ else }}
{{ if $isDisrupted }}
"disrupted"}
{{ else }}
{{ if $isNotice }}
"notice"}
{{ else }}
"ok"}
{{ 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:
https://github.com/cstate/cstate/blob/v3/layouts/api/single.html