How to use resources.Concat feature

I am trying to build my own theme. I have a partial named global-styles.html for styling the theme as follows:

{{ $fonts := resources.Get "fonts.css" | resources.ExecuteAsTemplate "fonts.css" . | minify | fingerprint -}}
	<link rel="stylesheet" href="{{ $fonts.RelPermalink }}" {{ printf "integrity=%q" $fonts.Data.Integrity | safeHTMLAttr }}>
{{ $style := resources.Get "scss/base.scss" | resources.ExecuteAsTemplate "css/style.css" . | toCSS | minify | fingerprint -}}
	<link rel="stylesheet" href="{{ $style.RelPermalink }}" {{ printf "integrity=%q" $style.Data.Integrity | safeHTMLAttr }}>

The partial works fine. But I would like to modify it with as result one single css file by using the resources.Concat feature but I did not succeed to have a proper syntax. Something likes slice $fonts $style | resources.Concat "styles.css".
As my coding skills are very limited, any help would be very appreciated.
Thank you in advance

1 Like

Try this (untested)

{{ $fonts := resources.Get "fonts.css" | resources.ExecuteAsTemplate "fonts.css" . }}
{{ $base := resources.Get "scss/base.scss" | resources.ExecuteAsTemplate "css/style.css" . | toCSS }}
{{ $styles := slice $fonts $base | resources.Concat "styles.css" | minify | fingerprint }}
<link rel="stylesheet" href="{{ $styles.RelPermalink }}" {{ printf "integrity=%q" $styles.Data.Integrity | safeHTMLAttr }}>
3 Likes

Thanks a lot for the swift answer.
It works like a charm !

One more question:
Is it possible to use the same rational with scripts (for example main.js + index.js) ?

Yep :+1: