diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2023-01-15 18:45:51 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2023-01-16 15:34:16 +0100 |
commit | f38a2fbd2e4de7f095a833b448cb8bc053955ce2 (patch) | |
tree | 3c88d0c12efa09ef3cc189a5859620b771004c7f /hugolib/config_test.go | |
parent | 6a579ebac3a81df61f22988e3eb55f7cb35ce523 (diff) |
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
Diffstat (limited to 'hugolib/config_test.go')
-rw-r--r-- | hugolib/config_test.go | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/hugolib/config_test.go b/hugolib/config_test.go index 882d83c8d..37605b4c2 100644 --- a/hugolib/config_test.go +++ b/hugolib/config_test.go @@ -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", + ) + + }) + } + +} |