diff options
author | Bjørn Erik Pedersen <[email protected]> | 2023-06-28 10:01:44 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2023-06-28 12:33:33 +0200 |
commit | 79639c981cf69193fb21d97773d928c089714750 (patch) | |
tree | 8a2965fe1b9fdb5c8db812d14cb5e2a58a090bba /config | |
parent | 9b313cec1bb6ee9b7f7e751a721e65fcdc35691b (diff) | |
download | hugo-79639c981cf69193fb21d97773d928c089714750.tar.gz hugo-79639c981cf69193fb21d97773d928c089714750.zip |
Fix output formats and media type per language config regression
Fixes #11159
Diffstat (limited to 'config')
-rw-r--r-- | config/allconfig/alldecoders.go | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/config/allconfig/alldecoders.go b/config/allconfig/alldecoders.go index 4d9ef4f85..bda3122d3 100644 --- a/config/allconfig/alldecoders.go +++ b/config/allconfig/alldecoders.go @@ -138,8 +138,8 @@ var allDecoderSetups = map[string]decodeWeight{ return err }, }, - "mediaTypes": { - key: "mediaTypes", + "mediatypes": { + key: "mediatypes", decode: func(d decodeWeight, p decodeConfig) error { var err error p.c.MediaTypes, err = media.DecodeTypes(p.p.GetStringMap(d.key)) @@ -168,8 +168,8 @@ var allDecoderSetups = map[string]decodeWeight{ return nil }, }, - "outputFormats": { - key: "outputFormats", + "outputformats": { + key: "outputformats", decode: func(d decodeWeight, p decodeConfig) error { var err error p.c.OutputFormats, err = output.DecodeConfig(p.c.MediaTypes.Config, p.p.Get(d.key)) @@ -221,9 +221,9 @@ var allDecoderSetups = map[string]decodeWeight{ // key = '...' // To sucessfully be backward compatible, "default" patterns need to be set for both page and term - p.c.Permalinks["page"][k] = v; - p.c.Permalinks["term"][k] = v; - + p.c.Permalinks["page"][k] = v + p.c.Permalinks["term"][k] = v + case maps.Params: // [permalinks.key] // xyz = ??? @@ -234,7 +234,7 @@ var allDecoderSetups = map[string]decodeWeight{ switch v2 := v2.(type) { case string: p.c.Permalinks[k][k2] = v2 - + default: return fmt.Errorf("permalinks configuration invalid: unknown value %q for key %q for kind %q", v2, k2, k) } @@ -410,3 +410,19 @@ var allDecoderSetups = map[string]decodeWeight{ }, }, } + +func init() { + for k, v := range allDecoderSetups { + // Verify that k and v.key is all lower case. + if k != strings.ToLower(k) { + panic(fmt.Sprintf("key %q is not lower case", k)) + } + if v.key != strings.ToLower(v.key) { + panic(fmt.Sprintf("key %q is not lower case", v.key)) + } + + if k != v.key { + panic(fmt.Sprintf("key %q is not the same as the map key %q", k, v.key)) + } + } +} |