mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-26 22:04:32 +02:00
committed by
Bjørn Erik Pedersen
parent
99958f90fe
commit
574c2959b8
@@ -29,8 +29,12 @@ type Client struct {
|
||||
|
||||
// New creates a new Client given a specification. Note that it is the media types
|
||||
// configured for the site that is used to match files to the correct minifier.
|
||||
func New(rs *resources.Spec) *Client {
|
||||
return &Client{rs: rs, m: minifiers.New(rs.MediaTypes, rs.OutputFormats)}
|
||||
func New(rs *resources.Spec) (*Client, error) {
|
||||
m, err := minifiers.New(rs.MediaTypes, rs.OutputFormats, rs.Cfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &Client{rs: rs, m: m}, nil
|
||||
}
|
||||
|
||||
type minifyTransformation struct {
|
||||
@@ -43,9 +47,7 @@ func (t *minifyTransformation) Key() internal.ResourceTransformationKey {
|
||||
}
|
||||
|
||||
func (t *minifyTransformation) Transform(ctx *resources.ResourceTransformationCtx) error {
|
||||
if err := t.m.Minify(ctx.InMediaType, ctx.To, ctx.From); err != nil {
|
||||
return err
|
||||
}
|
||||
_ = t.m.Minify(ctx.InMediaType, ctx.To, ctx.From)
|
||||
ctx.AddOutPathIdentifier(".min")
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user