This is a status page. I am trying to show, for each component, if it’s operational, disrupted, down, etc.
- An issue’s frontmatter looks like this:
---
Title: Elevated error rates
Description: Continuing the saga.
Date: 2018-07-02 21:00:00
Resolved: false
ResolvedWhen: 2018-07-02 21:45:12
Severity: disrupted
Affected:
- API
- Gateway
Section: issue
---
- The
config.yml
looks like this:
params:
# These are your systems. Change them to
# change the amount of components.
systems:
#-
# name: Client Area
# codename: panel
#-
# name: Minecraft
# codename: mc
#-
# name: Web Hosting
# codename: web
- Gateway
- API
- Media Proxy
- Now I want to show this stuff:
a) For finding these issues, I have $incidents
and $active
. These work properly and give me all active incidents of any component. (This is only setting up for the actual components’ div part.)
b) I define what my systems are (in this case API, Gateway, Media Proxy):
c) then I go through all of them, creating a div for each one. In this div, I have to show the title (which is just $this
) and then the status… which is where the problem arises.
d) For API
and Gateway
, {{ $activeComponentIssues }}
should show Pages(1)
, but for all of them I get Pages(0)
. Why? Am I using intersect incorrectly? Probably, but it doesn’t throw any errors.
{{ $incidents := where .Site.RegularPages “Params.section” “issue” }}
{{ $active := where $incidents “Params.resolved” “=” false }}
{{ $systems := .Site.Params.systems }}
{{ range $index, $systems }}
<div class="component" data-status="ok">
{{ $this := . }}
{{ . }}
<span class="component-status">
{{ $activeComponentIssues := where $active “Params.affected” “intersect” . }}
{{ $activeComponentIssues }}
{{ $thisIsNotice := where $activeComponentIssues “Params.severity” “=” “notice” }}
{{ $thisIsDisrupted := where $activeComponentIssues “Params.severity” “=” “disrupted” }}
{{ $thisIsDown := where $activeComponentIssues “Params.severity” “=” “down” }}
{{ if $thisIsDown }}
Major
{{ else }}
{{ if $thisIsDisrupted }}
Minor
{{ else }}
{{ if $thisIsNotice }}
Maintenance
{{ else }}
Operational
{{ end }}{{ end }}{{ end }}
</span>
</div>
{{ end }}