mirror of
https://github.com/gohugoio/hugo.git
synced 2025-03-24 18:04:04 +00:00
Rename MainSites to Sites
Having many *main* sites doesn't make much sense.
This commit is contained in:
parent
c4e7c37055
commit
c447b7dd6e
2 changed files with 12 additions and 12 deletions
|
@ -57,7 +57,7 @@ func benchmark(cmd *cobra.Command, args []string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for i := 0; i < benchmarkTimes; i++ {
|
for i := 0; i < benchmarkTimes; i++ {
|
||||||
MainSites = nil
|
Sites = nil
|
||||||
_ = buildSite()
|
_ = buildSite()
|
||||||
}
|
}
|
||||||
pprof.WriteHeapProfile(f)
|
pprof.WriteHeapProfile(f)
|
||||||
|
@ -76,7 +76,7 @@ func benchmark(cmd *cobra.Command, args []string) error {
|
||||||
pprof.StartCPUProfile(f)
|
pprof.StartCPUProfile(f)
|
||||||
defer pprof.StopCPUProfile()
|
defer pprof.StopCPUProfile()
|
||||||
for i := 0; i < benchmarkTimes; i++ {
|
for i := 0; i < benchmarkTimes; i++ {
|
||||||
MainSites = nil
|
Sites = nil
|
||||||
_ = buildSite()
|
_ = buildSite()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,10 +46,10 @@ import (
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MainSites represents the Hugo sites to build. This variable is exported as it
|
// Sites represents the Hugo sites to build. This variable is exported as it
|
||||||
// is used by at least one external library (the Hugo caddy plugin). We should
|
// is used by at least one external library (the Hugo caddy plugin). We should
|
||||||
// provide a cleaner external API, but until then, this is it.
|
// provide a cleaner external API, but until then, this is it.
|
||||||
var MainSites map[string]*hugolib.Site
|
var Sites map[string]*hugolib.Site
|
||||||
|
|
||||||
// Reset resets Hugo ready for a new full build. This is mainly only useful
|
// Reset resets Hugo ready for a new full build. This is mainly only useful
|
||||||
// for benchmark testing etc. via the CLI commands.
|
// for benchmark testing etc. via the CLI commands.
|
||||||
|
@ -510,7 +510,7 @@ func watchConfig() {
|
||||||
viper.OnConfigChange(func(e fsnotify.Event) {
|
viper.OnConfigChange(func(e fsnotify.Event) {
|
||||||
fmt.Println("Config file changed:", e.Name)
|
fmt.Println("Config file changed:", e.Name)
|
||||||
// Force a full rebuild
|
// Force a full rebuild
|
||||||
MainSites = nil
|
Sites = nil
|
||||||
utils.CheckErr(buildSite(true))
|
utils.CheckErr(buildSite(true))
|
||||||
if !viper.GetBool("DisableLiveReload") {
|
if !viper.GetBool("DisableLiveReload") {
|
||||||
// Will block forever trying to write to a channel that nobody is reading if livereload isn't initialized
|
// Will block forever trying to write to a channel that nobody is reading if livereload isn't initialized
|
||||||
|
@ -708,16 +708,16 @@ func buildSite(watching ...bool) (err error) {
|
||||||
fmt.Println("Started building site")
|
fmt.Println("Started building site")
|
||||||
t0 := time.Now()
|
t0 := time.Now()
|
||||||
|
|
||||||
if MainSites == nil {
|
if Sites == nil {
|
||||||
MainSites = make(map[string]*hugolib.Site)
|
Sites = make(map[string]*hugolib.Site)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, lang := range langConfigsList {
|
for _, lang := range langConfigsList {
|
||||||
t1 := time.Now()
|
t1 := time.Now()
|
||||||
mainSite, present := MainSites[lang.Lang]
|
mainSite, present := Sites[lang.Lang]
|
||||||
if !present {
|
if !present {
|
||||||
mainSite = new(hugolib.Site)
|
mainSite = new(hugolib.Site)
|
||||||
MainSites[lang.Lang] = mainSite
|
Sites[lang.Lang] = mainSite
|
||||||
mainSite.SetMultilingualConfig(lang, langConfigsList)
|
mainSite.SetMultilingualConfig(lang, langConfigsList)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -742,13 +742,13 @@ func rebuildSite(events []fsnotify.Event) error {
|
||||||
|
|
||||||
for _, lang := range langConfigsList {
|
for _, lang := range langConfigsList {
|
||||||
t1 := time.Now()
|
t1 := time.Now()
|
||||||
mainSite := MainSites[lang.Lang]
|
site := Sites[lang.Lang]
|
||||||
|
|
||||||
if err := mainSite.ReBuild(events); err != nil {
|
if err := site.ReBuild(events); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
mainSite.Stats(lang.Lang, t1)
|
site.Stats(lang.Lang, t1)
|
||||||
}
|
}
|
||||||
|
|
||||||
jww.FEEDBACK.Printf("total in %v ms\n", int(1000*time.Since(t0).Seconds()))
|
jww.FEEDBACK.Printf("total in %v ms\n", int(1000*time.Since(t0).Seconds()))
|
||||||
|
|
Loading…
Reference in a new issue