summaryrefslogtreecommitdiffstats
path: root/tpl
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2024-06-23 12:49:10 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2024-06-25 15:48:02 +0200
commite1317dd32281dc5ce670e34165dc7780c8f5892b (patch)
tree986f45feec6d2590b859697f7498f7f9a3cdcc1e /tpl
parenteddcd2bac6bfd3cc0ac1a3b38bf8c4ae452ea23b (diff)
Add css.TailwindCSS
Closes #12618 Closes #12620
Diffstat (limited to 'tpl')
-rw-r--r--tpl/css/css.go24
1 files changed, 20 insertions, 4 deletions
diff --git a/tpl/css/css.go b/tpl/css/css.go
index 145cb3aad..48a526c17 100644
--- a/tpl/css/css.go
+++ b/tpl/css/css.go
@@ -13,7 +13,7 @@ import (
"github.com/gohugoio/hugo/resources"
"github.com/gohugoio/hugo/resources/resource"
"github.com/gohugoio/hugo/resources/resource_transformers/babel"
- "github.com/gohugoio/hugo/resources/resource_transformers/postcss"
+ "github.com/gohugoio/hugo/resources/resource_transformers/cssjs"
"github.com/gohugoio/hugo/resources/resource_transformers/tocss/dartsass"
"github.com/gohugoio/hugo/resources/resource_transformers/tocss/scss"
"github.com/gohugoio/hugo/tpl/internal"
@@ -27,7 +27,8 @@ const name = "css"
type Namespace struct {
d *deps.Deps
scssClientLibSass *scss.Client
- postcssClient *postcss.Client
+ postcssClient *cssjs.PostCSSClient
+ tailwindcssClient *cssjs.TailwindCSSClient
babelClient *babel.Client
// The Dart Client requires a os/exec process, so only
@@ -63,7 +64,21 @@ func (ns *Namespace) PostCSS(args ...any) (resource.Resource, error) {
return ns.postcssClient.Process(r, m)
}
-// Sass processes the given Resource with Sass.
+// TailwindCSS processes the given Resource with tailwindcss.
+func (ns *Namespace) TailwindCSS(args ...any) (resource.Resource, error) {
+ if len(args) > 2 {
+ return nil, errors.New("must not provide more arguments than resource object and options")
+ }
+
+ r, m, err := resourcehelpers.ResolveArgs(args)
+ if err != nil {
+ return nil, err
+ }
+
+ return ns.tailwindcssClient.Process(r, m)
+}
+
+// Sass processes the given Resource with SASS.
func (ns *Namespace) Sass(args ...any) (resource.Resource, error) {
if len(args) > 2 {
return nil, errors.New("must not provide more arguments than resource object and options")
@@ -144,7 +159,8 @@ func init() {
ctx := &Namespace{
d: d,
scssClientLibSass: scssClient,
- postcssClient: postcss.New(d.ResourceSpec),
+ postcssClient: cssjs.NewPostCSSClient(d.ResourceSpec),
+ tailwindcssClient: cssjs.NewTailwindCSSClient(d.ResourceSpec),
babelClient: babel.New(d.ResourceSpec),
}