From: Bjørn Erik Pedersen Date: Thu, 10 Nov 2016 10:01:58 +0000 (+0100) Subject: node to page: Handle aliases on home page etc. X-Git-Tag: v0.18~103 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=2d91b17c;p=brevno-suite%2Fhugo node to page: Handle aliases on home page etc. Updates #2297 --- diff --git a/hugolib/node_as_page_test.go b/hugolib/node_as_page_test.go index 083bdc30..b871c301 100644 --- a/hugolib/node_as_page_test.go +++ b/hugolib/node_as_page_test.go @@ -325,8 +325,6 @@ categories: [ } func TestNodesWithMenu(t *testing.T) { - //jww.SetStdoutThreshold(jww.LevelDebug) - //defer jww.SetStdoutThreshold(jww.LevelFatal) testCommonResetState() writeLayoutsForNodeAsPageTests(t) @@ -353,6 +351,35 @@ menu: } +func TestNodesWithAlias(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 Alias +aliases: + - /my/new/home.html +--- +`) + + 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 Alias") + assertFileContent(t, filepath.Join("public", "my", "new", "home.html"), true, "content=\"0; url=/") + +} + func writeRegularPagesForNodeAsPageTests(t *testing.T) { writeRegularPagesForNodeAsPageTestsWithLang(t, "") } diff --git a/hugolib/site_render.go b/hugolib/site_render.go index 8777d91a..9a65987c 100644 --- a/hugolib/site_render.go +++ b/hugolib/site_render.go @@ -238,9 +238,8 @@ func (s *Site) renderRobotsTXT() error { } // renderAliases renders shell pages that simply have a redirect in the header. -// TODO(bep) np aliases of node types func (s *Site) renderAliases() error { - for _, p := range s.Pages { + for _, p := range s.Nodes { if len(p.Aliases) == 0 { continue }