conf := b.H.Configs.Base
b.Assert(conf.IsKindEnabled("term"), qt.Equals, false)
}
+
+// Issue #11000
+func TestConfigEmptyTOMLString(t *testing.T) {
+ t.Parallel()
+
+ files := `
+-- hugo.toml --
+[mediaTypes]
+[mediaTypes."text/htaccess"]
+suffixes = ["htaccess"]
+[outputFormats]
+[outputFormats.htaccess]
+mediaType = "text/htaccess"
+baseName = ""
+isPlainText = false
+notAlternative = true
+-- content/_index.md --
+---
+outputs: ["html", "htaccess"]
+---
+-- layouts/index.html --
+HTML.
+-- layouts/_default/list.htaccess --
+HTACCESS.
+
+
+
+`
+ b := NewIntegrationTestBuilder(
+ IntegrationTestConfig{
+ T: t,
+ TxtarString: files,
+ },
+ ).Build()
+
+ b.AssertFileContent("public/.htaccess", "HTACCESS")
+
+}
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))
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)
}