diff options
Diffstat (limited to 'minifiers/minifiers.go')
-rw-r--r-- | minifiers/minifiers.go | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/minifiers/minifiers.go b/minifiers/minifiers.go index 5a5cec121..2696e1c52 100644 --- a/minifiers/minifiers.go +++ b/minifiers/minifiers.go @@ -39,7 +39,7 @@ type Client struct { // Transformer returns a func that can be used in the transformer publishing chain. // TODO(bep) minify config etc func (m Client) Transformer(mediatype media.Type) transform.Transformer { - _, params, min := m.m.Match(mediatype.Type()) + _, params, min := m.m.Match(mediatype.Type) if min == nil { // No minifier for this MIME type return nil @@ -54,7 +54,7 @@ func (m Client) Transformer(mediatype media.Type) transform.Transformer { // Minify tries to minify the src into dst given a MIME type. func (m Client) Minify(mediatype media.Type, dst io.Writer, src io.Reader) error { - return m.m.Minify(mediatype.Type(), dst, src) + return m.m.Minify(mediatype.Type, dst, src) } // noopMinifier implements minify.Minifier [1], but doesn't minify content. This means @@ -74,13 +74,9 @@ func (m noopMinifier) Minify(_ *minify.M, w io.Writer, r io.Reader, _ map[string // New creates a new Client with the provided MIME types as the mapping foundation. // The HTML minifier is also registered for additional HTML types (AMP etc.) in the // provided list of output formats. -func New(mediaTypes media.Types, outputFormats output.Formats, cfg config.Provider) (Client, error) { - conf, err := decodeConfig(cfg) - +func New(mediaTypes media.Types, outputFormats output.Formats, cfg config.AllProvider) (Client, error) { + conf := cfg.GetConfigSection("minify").(MinifyConfig) m := minify.New() - if err != nil { - return Client{}, err - } // We use the Type definition of the media types defined in the site if found. addMinifier(m, mediaTypes, "css", getMinifier(conf, "css")) @@ -99,7 +95,7 @@ func New(mediaTypes media.Types, outputFormats output.Formats, cfg config.Provid addMinifier(m, mediaTypes, "html", getMinifier(conf, "html")) for _, of := range outputFormats { if of.IsHTML { - m.Add(of.MediaType.Type(), getMinifier(conf, "html")) + m.Add(of.MediaType.Type, getMinifier(conf, "html")) } } @@ -108,7 +104,7 @@ func New(mediaTypes media.Types, outputFormats output.Formats, cfg config.Provid // getMinifier returns the appropriate minify.MinifierFunc for the MIME // type suffix s, given the config c. -func getMinifier(c minifyConfig, s string) minify.Minifier { +func getMinifier(c MinifyConfig, s string) minify.Minifier { switch { case s == "css" && !c.DisableCSS: return &c.Tdewolff.CSS @@ -130,6 +126,6 @@ func getMinifier(c minifyConfig, s string) minify.Minifier { func addMinifier(m *minify.M, mt media.Types, suffix string, min minify.Minifier) { types := mt.BySuffix(suffix) for _, t := range types { - m.Add(t.Type(), min) + m.Add(t.Type, min) } } |