Skip to content

Commit

Permalink
hugolib: Finish menu vs section content pages
Browse files Browse the repository at this point in the history
This commit also fixes the default menu sort when the weight is 0.

Closes #2974
  • Loading branch information
bep committed Feb 20, 2017
1 parent 2a6b26a commit a3af4fe
Show file tree
Hide file tree
Showing 9 changed files with 816 additions and 704 deletions.
1 change: 1 addition & 0 deletions hugolib/hugo_sites_build.go
Expand Up @@ -167,6 +167,7 @@ func (h *HugoSites) assemble(config *BuildCfg) error {
}

for _, s := range h.Sites {
s.assembleMenus()
s.refreshPageCaches()
s.setupSitePages()
}
Expand Down
4 changes: 2 additions & 2 deletions hugolib/hugo_sites_build_test.go
Expand Up @@ -1235,11 +1235,11 @@ lag:
return sites
}

func writeSource(t *testing.T, fs *hugofs.Fs, filename, content string) {
func writeSource(t testing.TB, fs *hugofs.Fs, filename, content string) {
writeToFs(t, fs.Source, filename, content)
}

func writeToFs(t *testing.T, fs afero.Fs, filename, content string) {
func writeToFs(t testing.TB, fs afero.Fs, filename, content string) {
if err := afero.WriteFile(fs, filepath.FromSlash(filename), []byte(content), 0755); err != nil {
t.Fatalf("Failed to write file: %s", err)
}
Expand Down
9 changes: 9 additions & 0 deletions hugolib/menu.go
Expand Up @@ -157,6 +157,15 @@ var defaultMenuEntrySort = func(m1, m2 *MenuEntry) bool {
}
return m1.Name < m2.Name
}

if m2.Weight == 0 {
return true
}

if m1.Weight == 0 {
return false
}

return m1.Weight < m2.Weight
}

Expand Down

0 comments on commit a3af4fe

Please sign in to comment.