node to page: Handle aliases on home page etc.

Updates #2297
This commit is contained in:
Bjørn Erik Pedersen 2016-11-10 11:01:58 +01:00
parent 7cb0e34dce
commit 2d91b17c04
2 changed files with 30 additions and 4 deletions

View file

@ -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, "")
}

View file

@ -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
}