add safeguards

This commit is contained in:
Niklas Buschmann 2020-02-20 15:16:34 +01:00
parent 9a0504b33b
commit 1230c7959d

View File

@ -27,11 +27,15 @@
{{ range $menu, $items := .Site.Menus }} {{ range $menu, $items := .Site.Menus }}
<nav> <nav>
{{ range $items }} {{ range $items }}
<a href="{{ .URL }}" {{ if (eq $.RelPermalink .URL) }}class="selected"{{ end }}>
{{ if and .Identifier (index $.Site.Data.fontawesome.icons .Identifier) }}
{{ $icon := index $.Site.Data.fontawesome.icons .Identifier }} {{ $icon := index $.Site.Data.fontawesome.icons .Identifier }}
{{ $svg := $icon.svg.solid | default $icon.svg.regular | default $icon.svg.brands }} {{ $svg := $icon.svg.solid | default $icon.svg.regular | default $icon.svg.brands }}
<a href="{{ .URL }}" {{ if (eq $.RelPermalink .URL) }}class="selected"{{ end }}>
<span {{ if eq $menu "main" }}class="hidden"{{ end }}>{{ safeHTML $svg.raw }}</span> <span {{ if eq $menu "main" }}class="hidden"{{ end }}>{{ safeHTML $svg.raw }}</span>
<span {{ if not (eq $menu "main") }}class="hidden"{{ end }}>{{ .Name }}</span> <span {{ if not (eq $menu "main") }}class="hidden"{{ end }}>{{ .Name }}</span>
{{ else }}
{{ .Name }}
{{ end }}
</a> </a>
{{ end }} {{ end }}
</nav> </nav>