mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-20 21:31:32 +02:00
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:
@@ -69,18 +69,35 @@ func LoadConfig(d ConfigSourceDescriptor, doWithConfig ...func(cfg config.Provid
|
||||
// use a partial configuration to do its job.
|
||||
defer l.deleteMergeStrategies()
|
||||
|
||||
for _, name := range d.configFilenames() {
|
||||
var filename string
|
||||
filename, err := l.loadConfig(name)
|
||||
if err == nil {
|
||||
configFiles = append(configFiles, filename)
|
||||
} else if err != ErrNoConfigFile {
|
||||
return nil, nil, l.wrapFileError(err, filename)
|
||||
names := d.configFilenames()
|
||||
|
||||
if names != nil {
|
||||
for _, name := range names {
|
||||
var filename string
|
||||
filename, err := l.loadConfig(name)
|
||||
if err == nil {
|
||||
configFiles = append(configFiles, filename)
|
||||
} else if err != ErrNoConfigFile {
|
||||
return nil, nil, l.wrapFileError(err, filename)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for _, name := range config.DefaultConfigNames {
|
||||
var filename string
|
||||
filename, err := l.loadConfig(name)
|
||||
if err == nil {
|
||||
configFiles = append(configFiles, filename)
|
||||
break
|
||||
} else if err != ErrNoConfigFile {
|
||||
return nil, nil, l.wrapFileError(err, filename)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if d.AbsConfigDir != "" {
|
||||
|
||||
dcfg, dirnames, err := config.LoadConfigFromDir(l.Fs, d.AbsConfigDir, l.Environment)
|
||||
|
||||
if err == nil {
|
||||
if len(dirnames) > 0 {
|
||||
l.cfg.Set("", dcfg.Get(""))
|
||||
@@ -162,9 +179,9 @@ func LoadConfig(d ConfigSourceDescriptor, doWithConfig ...func(cfg config.Provid
|
||||
return l.cfg, configFiles, err
|
||||
}
|
||||
|
||||
// LoadConfigDefault is a convenience method to load the default "config.toml" config.
|
||||
// LoadConfigDefault is a convenience method to load the default "hugo.toml" config.
|
||||
func LoadConfigDefault(fs afero.Fs) (config.Provider, error) {
|
||||
v, _, err := LoadConfig(ConfigSourceDescriptor{Fs: fs, Filename: "config.toml"})
|
||||
v, _, err := LoadConfig(ConfigSourceDescriptor{Fs: fs})
|
||||
return v, err
|
||||
}
|
||||
|
||||
@@ -202,7 +219,7 @@ func (d ConfigSourceDescriptor) configFileDir() string {
|
||||
|
||||
func (d ConfigSourceDescriptor) configFilenames() []string {
|
||||
if d.Filename == "" {
|
||||
return []string{"config"}
|
||||
return nil
|
||||
}
|
||||
return strings.Split(d.Filename, ",")
|
||||
}
|
||||
|
Reference in New Issue
Block a user