Skip to content

Commit

Permalink
node to page: Handle menus on home page etc.
Browse files Browse the repository at this point in the history
Updates #2297
  • Loading branch information
bep committed Nov 22, 2016
1 parent ecedc85 commit 7cb0e34
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
37 changes: 34 additions & 3 deletions hugolib/node_as_page_test.go
Expand Up @@ -296,8 +296,6 @@ title = "Hugo in English"
}

func TestNodesWithTaxonomies(t *testing.T) {
//jww.SetStdoutThreshold(jww.LevelDebug)
//defer jww.SetStdoutThreshold(jww.LevelFatal)
testCommonResetState()

writeLayoutsForNodeAsPageTests(t)
Expand All @@ -314,7 +312,6 @@ categories: [

viper.Set("paginate", 1)
viper.Set("title", "Hugo Rocks!")
viper.Set("rssURI", "customrss.xml")

s := newSiteDefaultLang()

Expand All @@ -327,6 +324,35 @@ categories: [

}

func TestNodesWithMenu(t *testing.T) {
//jww.SetStdoutThreshold(jww.LevelDebug)
//defer jww.SetStdoutThreshold(jww.LevelFatal)
testCommonResetState()

writeLayoutsForNodeAsPageTests(t)
writeRegularPagesForNodeAsPageTests(t)

writeSource(t, filepath.Join("content", "_index.md"), `---
title: Home With Menu
menu:
mymenu:
name: "Go Home!"
---
`)

viper.Set("paginate", 1)
viper.Set("title", "Hugo Rocks!")

s := newSiteDefaultLang()

if err := buildAndRenderSite(s); err != nil {
t.Fatalf("Failed to build site: %s", err)
}

assertFileContent(t, filepath.Join("public", "index.html"), true, "Home With Menu", "Menu Item: Go Home!")

}

func writeRegularPagesForNodeAsPageTests(t *testing.T) {
writeRegularPagesForNodeAsPageTestsWithLang(t, "")
}
Expand Down Expand Up @@ -408,6 +434,11 @@ Index Content: {{ .Content }}
{{ range .Paginator.Pages }}
Pag: {{ .Title }}
{{ end }}
{{ with .Site.Menus.mymenu }}
{{ range . }}
Menu Item: {{ .Name }}
{{ end }}
{{ end }}
`)

writeSource(t, filepath.Join("layouts", "_default", "single.html"), `
Expand Down
3 changes: 1 addition & 2 deletions hugolib/site.go
Expand Up @@ -1427,8 +1427,7 @@ func (s *Site) assembleMenus() {
sectionPagesMenu := s.Language.GetString("SectionPagesMenu")
sectionPagesMenus := make(map[string]interface{})
//creating flat hash
// TODO(bep) np menu
pages := s.findPagesByNodeType(NodePage)
pages := s.Nodes
for _, p := range pages {

if sectionPagesMenu != "" {
Expand Down

0 comments on commit 7cb0e34

Please sign in to comment.