Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-09-16 20:41:43 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-09-19 22:17:02 +0300
commitb254532b52785954c98a473a635b9cea016d8565 (patch)
treec22fa7e40311c6b75e45320a53136b2b4720e881 /minifiers/config.go
parent05a22892921bd4618efe6135ce0d6fe2be545607 (diff)
deps: Update to github.com/tdewolff/minify v2.9.4
Diffstat (limited to 'minifiers/config.go')
-rw-r--r--minifiers/config.go27
1 files changed, 21 insertions, 6 deletions
diff --git a/minifiers/config.go b/minifiers/config.go
index 5ee3aa2f9..0715344a7 100644
--- a/minifiers/config.go
+++ b/minifiers/config.go
@@ -18,6 +18,7 @@ import (
"github.com/gohugoio/hugo/config"
"github.com/gohugoio/hugo/docshelper"
"github.com/gohugoio/hugo/parser"
+ "github.com/spf13/cast"
"github.com/mitchellh/mapstructure"
"github.com/tdewolff/minify/v2/css"
@@ -35,18 +36,16 @@ var defaultTdewolffConfig = tdewolffConfig{
KeepEndTags: true,
KeepDefaultAttrVals: true,
KeepWhitespace: false,
- // KeepQuotes: false, >= v2.6.2
+ KeepQuotes: false,
},
CSS: css.Minifier{
- Decimals: -1, // will be deprecated
- // Precision: 0, // use Precision with >= v2.7.0
- KeepCSS2: true,
+ Precision: 0,
+ KeepCSS2: true,
},
JS: js.Minifier{},
JSON: json.Minifier{},
SVG: svg.Minifier{
- Decimals: -1, // will be deprecated
- // Precision: 0, // use Precision with >= v2.7.0
+ Precision: 0,
},
XML: xml.Minifier{
KeepWhitespace: false,
@@ -99,6 +98,22 @@ func decodeConfig(cfg config.Provider) (conf minifyConfig, err error) {
m := maps.ToStringMap(v)
+ // Handle upstream renames.
+ if td, found := m["tdewolff"]; found {
+ tdm := cast.ToStringMap(td)
+ for _, key := range []string{"css", "svg"} {
+ if v, found := tdm[key]; found {
+ vm := cast.ToStringMap(v)
+ if vv, found := vm["decimal"]; found {
+ vvi := cast.ToInt(vv)
+ if vvi > 0 {
+ vm["precision"] = vvi
+ }
+ }
+ }
+ }
+ }
+
err = mapstructure.WeakDecode(m, &conf)
if err != nil {