aboutsummaryrefslogtreecommitdiffhomepage
path: root/output
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2023-05-23 17:39:49 +0200
committerBjørn Erik Pedersen <[email protected]>2023-05-23 19:23:39 +0200
commited906a86e2f991adb5c528be6905d188b3f4d2ac (patch)
tree26cc70564eaa21872006d22ac97eb0c05432c552 /output
parentd666edad71b027e344a255810d1803a054a7bd4d (diff)
downloadhugo-ed906a86e2f991adb5c528be6905d188b3f4d2ac.tar.gz
hugo-ed906a86e2f991adb5c528be6905d188b3f4d2ac.zip
Fix regression when config for OutputFormat.BaseName is an empty string
Fixes #11000
Diffstat (limited to 'output')
-rw-r--r--output/config.go15
1 files changed, 6 insertions, 9 deletions
diff --git a/output/config.go b/output/config.go
index 7b83ef9de..86e5bcfaa 100644
--- a/output/config.go
+++ b/output/config.go
@@ -32,6 +32,11 @@ type OutputFormatConfig struct {
Format
}
+var defaultOutputFormat = Format{
+ BaseName: "index",
+ Rel: "alternate",
+}
+
func DecodeConfig(mediaTypes media.Types, in any) (*config.ConfigNamespace[map[string]OutputFormatConfig, Formats], error) {
buildConfig := func(in any) (Formats, any, error) {
f := make(Formats, len(DefaultFormats))
@@ -59,20 +64,12 @@ func DecodeConfig(mediaTypes media.Types, in any) (*config.ConfigNamespace[map[s
continue
}
- var newOutFormat Format
+ newOutFormat := defaultOutputFormat
newOutFormat.Name = k
if err := decode(mediaTypes, v, &newOutFormat); err != nil {
return f, nil, err
}
- // We need values for these
- if newOutFormat.BaseName == "" {
- newOutFormat.BaseName = "index"
- }
- if newOutFormat.Rel == "" {
- newOutFormat.Rel = "alternate"
- }
-
f = append(f, newOutFormat)
}