Make hugo.toml the new config.toml

Both will of course work, but hugo.toml will win if both are set.

We should have done this a long time ago, of course, but the reason I'm picking this up now is that my VS Code setup by default picks up some
JSON config schema from some random other software which also names its config files config.toml.

Fixes #8979
This commit is contained in:
Bjørn Erik Pedersen
2023-01-15 18:45:51 +01:00
parent 6a579ebac3
commit f38a2fbd2e
7 changed files with 111 additions and 24 deletions

View File

@@ -782,3 +782,55 @@ defaultMarkdownHandler = 'blackfriday'
b.Assert(err.Error(), qt.Contains, "Configured defaultMarkdownHandler \"blackfriday\" not found. Did you mean to use goldmark? Blackfriday was removed in Hugo v0.100.0.")
}
// Issue 8979
func TestHugoConfig(t *testing.T) {
filesTemplate := `
-- hugo.toml --
theme = "mytheme"
[params]
rootparam = "rootvalue"
-- config/_default/hugo.toml --
[params]
rootconfigparam = "rootconfigvalue"
-- themes/mytheme/config/_default/hugo.toml --
[params]
themeconfigdirparam = "themeconfigdirvalue"
-- themes/mytheme/hugo.toml --
[params]
themeparam = "themevalue"
-- layouts/index.html --
rootparam: {{ site.Params.rootparam }}
rootconfigparam: {{ site.Params.rootconfigparam }}
themeparam: {{ site.Params.themeparam }}
themeconfigdirparam: {{ site.Params.themeconfigdirparam }}
`
for _, configName := range []string{"hugo.toml", "config.toml"} {
configName := configName
t.Run(configName, func(t *testing.T) {
t.Parallel()
files := strings.ReplaceAll(filesTemplate, "hugo.toml", configName)
b, err := NewIntegrationTestBuilder(
IntegrationTestConfig{
T: t,
TxtarString: files,
},
).BuildE()
b.Assert(err, qt.IsNil)
b.AssertFileContent("public/index.html",
"rootparam: rootvalue",
"rootconfigparam: rootconfigvalue",
"themeparam: themevalue",
"themeconfigdirparam: themeconfigdirvalue",
)
})
}
}