One CSS file for a page

Hello. I have many CSS files for a page

{{ $temp_css:= "components/switcher.css,modules/section_title.css" }}
{{ $css:= split $temp_css "," }}

And now I want to Combine all these CSS into one file.

I know variant

{{ $style := slice (resources.Get "components/switcher.css") (resources.Get "modules/section_title.css") | resources.Concat "css/test-all.css" | resources.Minify | resources.Fingerprint }}
<link rel="stylesheet" href="{{ $style.Permalink }}" type="text/css" media="all">

I can’t use this variant because I get $temp_css from .md files. Can u help me?

  {{ $temp_css := "components/switcher.css,modules/section_title.css" }}
  {{ $css := split $temp_css "," }}
  
  {{- $res := slice -}}
  
  {{- range $css -}}
    {{- $res = $res | append (resources.Get . ) -}}
  {{- end -}}
  
  {{ $style := $res | resources.Concat "css/test-all.css" | resources.Minify | resources.Fingerprint }}
  <link rel="stylesheet" href="{{ $style.Permalink }}" type="text/css" media="all">

The range should be replaced by apply, but somehow apply failed to find resources.Get function? a bug?

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.