{{ if eq hugo.Environment "gitea" }}
<link rel="stylesheet" href="/css/styles.css">
{{ else if .Site.IsServer }}
  {{ $style := resources.Get "css/styles.css" | postCSS (dict "config" "./assets/css/postcss.config.js") | minify | fingerprint }}
  <link rel="stylesheet" href="{{ $style.Permalink }}" integrity="{{ $style.Data.Integrity }}">
{{ else }}
  {{ $flist := newScratch }}
    {{ $flist.Set "initial" "nop" }}
    {{ range (readDir "public/css") }}
      {{ $finfo := os.Stat (printf "%s%s" "public/css/" .Name) }}
      {{ $flist.SetInMap "css_files" (printf "%s" $finfo.ModTime) .Name }}
      {{ $flist.Set "initial" "yay" }}
    {{ end }}

    {{ $css := "nop" }}

    {{ if eq ($flist.Get "initial") "yay" }}
      {{ $css = (index (last 1 ( $flist.GetSortedMapValues "css_files" )) 0) }}
    {{ end }}

    {{ if in $css "css" }}
      <link rel="stylesheet" href="{{ "/css/" }}{{ $css }}">
    {{ else }}
      {{ $style := resources.Get "css/styles.css" | postCSS (dict "config" "./assets/css/postcss.config.js") | minify | fingerprint }}
      <link rel="stylesheet" href="{{ $style.Permalink }}" integrity="{{ $style.Data.Integrity }}">
    {{ end }}
{{ end }}
