{{ define "main" }}

{{ .Scratch.Set "skipSeeAlso" true }}

{{ partial "primary_top.html" . }}

<p>{{ .Description }}</p>

<div class="security-grid">
    {{ $pages := (where .Site.Pages "Section" .Section) }}
    {{ $pages = sort $pages ".Params.publishdate" "desc" }}

    {{ $parent := .Page }}
    {{ $parentDir := (path.Dir .Page.File.Dir) }}

    <table>
        <thead>
            <tr>
                <th>{{ i18n "security_disclosure" }}</th>
                <th>{{ i18n "security_date" }}</th>
                <th>{{ i18n "security_affected_releases" }}</th>
                <th>{{ i18n "security_impact_score" }}</th>
                <th>{{ i18n "security_related" }}</th>
            </tr>
        </thead>
        <tbody>
            {{ $decoration := .Params.decoration }}
            {{ range $pages }}
                {{ $pageLocation := (path.Dir (path.Dir .File.Dir)) }}
                {{ if and (eq $parentDir $pageLocation) (not .Params.draft) }}
                    <tr>
                        <td><a href="{{ .Permalink }}">{{ .LinkTitle }}
                            {{- if $decoration -}}<i class="{{ $decoration }}" data-prefix="{{ .RelPermalink }}"></i>{{- end -}}
                        </a></td>

                        <td>{{ .PublishDate.Format (i18n "page_publish_date_format") -}}</td>

                        <td>
                            {{ range .Params.releases }}
                                {{ trim . " " }}<br>
                            {{ end }}
                        </td>

                        <td class="score">
                            {{ if .Params.cvss }}
                                <a href="https://nvd.nist.gov/vuln-metrics/cvss/v3-calculator?vector={{ .Params.vector }}">{{ .Params.cvss }}</a>
                            {{ end }}
                        </td>

                        <td>{{ trim .Description "." -}}</td>
                    </tr>
                {{ end }}
            {{ end }}
        </tbody>
    </table>
</div>

{{ partial "primary_bottom.html" . }}

{{ end }}
