Skip to content

Commit

Permalink
hugolib: Avoid repeated Viper loads of sectionPagesMenu
Browse files Browse the repository at this point in the history
See #2728
  • Loading branch information
bep committed Nov 24, 2016
1 parent dbb0c1c commit 1f6e0de
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion hugolib/page.go
Expand Up @@ -1092,7 +1092,7 @@ func (p *Page) getParam(key string, stringToLower bool) interface{} {

func (p *Page) HasMenuCurrent(menuID string, me *MenuEntry) bool {

sectionPagesMenu := helpers.Config().GetString("SectionPagesMenu")
sectionPagesMenu := p.Site.sectionPagesMenu

// page is labeled as "shadow-member" of the menu with the same identifier as the section
if sectionPagesMenu != "" && p.Section() != "" && sectionPagesMenu == menuID && p.Section() == me.Identifier {
Expand Down
4 changes: 3 additions & 1 deletion hugolib/site.go
Expand Up @@ -191,6 +191,7 @@ type SiteInfo struct {
LanguagePrefix string
Languages helpers.Languages
defaultContentLanguageInSubdir bool
sectionPagesMenu string

pathSpec *helpers.PathSpec
}
Expand Down Expand Up @@ -937,6 +938,7 @@ func (s *Site) initializeSiteInfo() {
LanguagePrefix: languagePrefix,
Languages: languages,
defaultContentLanguageInSubdir: defaultContentInSubDir,
sectionPagesMenu: lang.GetString("sectionPagesMenu"),
GoogleAnalytics: lang.GetString("googleAnalytics"),
BuildDrafts: viper.GetBool("buildDrafts"),
canonifyURLs: viper.GetBool("canonifyURLs"),
Expand Down Expand Up @@ -1412,7 +1414,7 @@ func (s *Site) assembleMenus() {
}
}

sectionPagesMenu := s.Language.GetString("sectionPagesMenu")
sectionPagesMenu := s.Info.sectionPagesMenu
sectionPagesMenus := make(map[string]interface{})
//creating flat hash
pages := s.Pages
Expand Down

0 comments on commit 1f6e0de

Please sign in to comment.