{{ if (or (eq hugo.Environment "gitea") (eq hugo.Environment "preview") ) }}
<link rel="stylesheet" href="/css/site.css">
{{ else if .Site.IsServer }}
  {{ $style := resources.Get "css/site.css" | postCSS (dict "config" "./assets/css/postcss.config.js") | minify }}
  <link rel="stylesheet" href="{{ $style.Permalink }}">
{{ 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/site.css" | postCSS (dict "config" "./assets/css/postcss.config.js") | minify }}
      <link rel="stylesheet" href="{{ $style.Permalink }}">
    {{ end }}
{{ end }}
