mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-25 22:00:58 +02:00
Create a struct with all of Hugo's config options
Primary motivation is documentation, but it will also hopefully simplify the code. Also, * Lower case the default output format names; this is in line with the custom ones (map keys) and how it's treated all the places. This avoids doing `stringds.EqualFold` everywhere. Closes #10896 Closes #10620
This commit is contained in:
@@ -32,18 +32,18 @@ func TestDecodeConfig(t *testing.T) {
|
||||
imagingConfig, err := DecodeConfig(m)
|
||||
|
||||
c.Assert(err, qt.IsNil)
|
||||
imaging := imagingConfig.Cfg
|
||||
c.Assert(imaging.Quality, qt.Equals, 42)
|
||||
c.Assert(imaging.ResampleFilter, qt.Equals, "nearestneighbor")
|
||||
c.Assert(imaging.Anchor, qt.Equals, "topleft")
|
||||
conf := imagingConfig.Config
|
||||
c.Assert(conf.Imaging.Quality, qt.Equals, 42)
|
||||
c.Assert(conf.Imaging.ResampleFilter, qt.Equals, "nearestneighbor")
|
||||
c.Assert(conf.Imaging.Anchor, qt.Equals, "topleft")
|
||||
|
||||
m = map[string]any{}
|
||||
|
||||
imagingConfig, err = DecodeConfig(m)
|
||||
c.Assert(err, qt.IsNil)
|
||||
imaging = imagingConfig.Cfg
|
||||
c.Assert(imaging.ResampleFilter, qt.Equals, "box")
|
||||
c.Assert(imaging.Anchor, qt.Equals, "smart")
|
||||
conf = imagingConfig.Config
|
||||
c.Assert(conf.Imaging.ResampleFilter, qt.Equals, "box")
|
||||
c.Assert(conf.Imaging.Anchor, qt.Equals, "smart")
|
||||
|
||||
_, err = DecodeConfig(map[string]any{
|
||||
"quality": 123,
|
||||
@@ -63,9 +63,9 @@ func TestDecodeConfig(t *testing.T) {
|
||||
imagingConfig, err = DecodeConfig(map[string]any{
|
||||
"anchor": "Smart",
|
||||
})
|
||||
imaging = imagingConfig.Cfg
|
||||
conf = imagingConfig.Config
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(imaging.Anchor, qt.Equals, "smart")
|
||||
c.Assert(conf.Imaging.Anchor, qt.Equals, "smart")
|
||||
|
||||
imagingConfig, err = DecodeConfig(map[string]any{
|
||||
"exif": map[string]any{
|
||||
@@ -73,9 +73,9 @@ func TestDecodeConfig(t *testing.T) {
|
||||
},
|
||||
})
|
||||
c.Assert(err, qt.IsNil)
|
||||
imaging = imagingConfig.Cfg
|
||||
c.Assert(imaging.Exif.DisableLatLong, qt.Equals, true)
|
||||
c.Assert(imaging.Exif.ExcludeFields, qt.Equals, "GPS|Exif|Exposure[M|P|B]|Contrast|Resolution|Sharp|JPEG|Metering|Sensing|Saturation|ColorSpace|Flash|WhiteBalance")
|
||||
conf = imagingConfig.Config
|
||||
c.Assert(conf.Imaging.Exif.DisableLatLong, qt.Equals, true)
|
||||
c.Assert(conf.Imaging.Exif.ExcludeFields, qt.Equals, "GPS|Exif|Exposure[M|P|B]|Contrast|Resolution|Sharp|JPEG|Metering|Sensing|Saturation|ColorSpace|Flash|WhiteBalance")
|
||||
}
|
||||
|
||||
func TestDecodeImageConfig(t *testing.T) {
|
||||
@@ -123,7 +123,7 @@ func TestDecodeImageConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
func newImageConfig(action string, width, height, quality, rotate int, filter, anchor, bgColor string) ImageConfig {
|
||||
var c ImageConfig = GetDefaultImageConfig(action, ImagingConfig{})
|
||||
var c ImageConfig = GetDefaultImageConfig(action, nil)
|
||||
c.TargetFormat = PNG
|
||||
c.Hint = 2
|
||||
c.Width = width
|
||||
|
Reference in New Issue
Block a user