<!-- use default fontawesome class 'fas' or use a specified one like 'fab' for brands -->
{{ $faStylePrefix := "fas" }}
{{ if in (slice "fas" "far" "fal" "fad" "fab") (.Get 0) }}
  {{ $faStylePrefix = (.Get 0) }}
{{ end }}

<i class="{{ $faStylePrefix }} {{ range $iconName := .Params }} fa-{{ $iconName }} {{ end }}">
  <!-- Load font awesome only once per page, load it inside the <i> element
    so it does not disturb the text flow (like removing spaces) -->
  {{ if not (.Page.Scratch.Get "fontawesomeLoaded") }}
    {{ .Page.Scratch.Set "fontawesomeLoaded" true }}
    <link href="css/font-awesome.css" rel="stylesheet">
  {{ end }}
</i>
