summaryrefslogtreecommitdiffstats
path: root/resources/resource_transformers/tocss
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-08-18 11:21:27 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-08-26 15:00:44 +0200
commitf9978ed16476ca6d233a89669c62c798cdf9db9d (patch)
tree02edb31008b997a3e77055060a34971fe9e8c5a4 /resources/resource_transformers/tocss
parent58d4c0a8be8beefbd7437b17bf7a9a381164d09b (diff)
Image resource refactor
This commit pulls most of the image related logic into its own package, to make it easier to reason about and extend. This is also a rewrite of the transformation logic used in Hugo Pipes, mostly to allow constructs like the one below: {{ ($myimg | fingerprint ).Width }} Fixes #5903 Fixes #6234 Fixes #6266
Diffstat (limited to 'resources/resource_transformers/tocss')
-rw-r--r--resources/resource_transformers/tocss/scss/client.go12
1 files changed, 5 insertions, 7 deletions
diff --git a/resources/resource_transformers/tocss/scss/client.go b/resources/resource_transformers/tocss/scss/client.go
index e69af2f74..ddf51f7fe 100644
--- a/resources/resource_transformers/tocss/scss/client.go
+++ b/resources/resource_transformers/tocss/scss/client.go
@@ -18,6 +18,7 @@ import (
"github.com/gohugoio/hugo/helpers"
"github.com/gohugoio/hugo/hugolib/filesystems"
"github.com/gohugoio/hugo/resources"
+ "github.com/gohugoio/hugo/resources/internal"
"github.com/gohugoio/hugo/resources/resource"
"github.com/spf13/afero"
@@ -68,7 +69,7 @@ type options struct {
to scss.Options
}
-func (c *Client) ToCSS(res resource.Resource, opts Options) (resource.Resource, error) {
+func (c *Client) ToCSS(res resources.ResourceTransformer, opts Options) (resource.Resource, error) {
internalOptions := options{
from: opts,
}
@@ -83,10 +84,7 @@ func (c *Client) ToCSS(res resource.Resource, opts Options) (resource.Resource,
internalOptions.to.Precision = 8
}
- return c.rs.Transform(
- res,
- &toCSSTransformation{c: c, options: internalOptions},
- )
+ return res.Transform(&toCSSTransformation{c: c, options: internalOptions})
}
type toCSSTransformation struct {
@@ -94,8 +92,8 @@ type toCSSTransformation struct {
options options
}
-func (t *toCSSTransformation) Key() resources.ResourceTransformationKey {
- return resources.NewResourceTransformationKey("tocss", t.options.from)
+func (t *toCSSTransformation) Key() internal.ResourceTransformationKey {
+ return internal.NewResourceTransformationKey("tocss", t.options.from)
}
func DecodeOptions(m map[string]interface{}) (opts Options, err error) {