{{/*
  style/GetMainCSS
  Process the main css stylesheet and return as resource

  @author @regisphilibert

  @context Any (.)

  @returns Resource

  @uses
     - func/style/GetResource
*/}}
{{ $main_style := dict }}

{{/* We prepare a slice of resources to be concatenated as one */}}
{{ $assets_to_concat := slice }}
{{/* We add locale css files to the slice in the proper order */}}
{{ range slice "_tachyons.css" "_code.css" "_hugo-internal-templates.css" "_social-icons.css" "_styles" }}
  {{ with partialCached "func/style/GetResource" . . }}
    {{ $assets_to_concat = $assets_to_concat | append . }}
  {{ end }}
{{ end }}

{{/* We look for any custom css files registered by the user under `site.params.custom_css and if found in the theme's 
css asset directory we add to aforementioned slice */}}
{{ with site.Params.custom_css }}
  {{ range . }}
    {{ with partialCached "func/style/GetResource" . . }}
      {{ $assets_to_concat = $assets_to_concat | append . }}
    {{ end }}
  {{ end }}
{{ end }}

{{ with $assets_to_concat }}
  {{/* We proceed to concatenate the $assets_to_concat */}}
  {{ $style := . | resources.Concat "ananke/css/main.css" }}

  {{/* We then use toCSS to add sourceMap and minify */}}
  {{ $options := dict "enableSourceMap" true "precision" 6 }}
  {{ $style = $style | resources.ToCSS $options | minify }}
  {{/* We fingerprint in production for cache busting purposes */}}
  {{ if eq (getenv "HUGO_ENV") "production" }}
    {{ $style = $style | fingerprint }}
  {{ end }}
  {{/* We're ready to set returning variable with resulting resource */}}
  {{ $main_style = $style }}
{{ end }}

{{ return $main_style }}