mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
parent
d3d3863c05
commit
ecedc85cb7
2 changed files with 64 additions and 35 deletions
|
@ -152,22 +152,7 @@ func TestNodesWithNoContentFile(t *testing.T) {
|
||||||
testCommonResetState()
|
testCommonResetState()
|
||||||
|
|
||||||
writeLayoutsForNodeAsPageTests(t)
|
writeLayoutsForNodeAsPageTests(t)
|
||||||
|
writeRegularPagesForNodeAsPageTests(t)
|
||||||
for i := 1; i <= 4; i++ {
|
|
||||||
sect := "sect1"
|
|
||||||
if i > 2 {
|
|
||||||
sect = "sect2"
|
|
||||||
}
|
|
||||||
writeSource(t, filepath.Join("content", sect, fmt.Sprintf("regular%d.md", i)), fmt.Sprintf(`---
|
|
||||||
title: Page %02d
|
|
||||||
categories: [
|
|
||||||
"Hugo",
|
|
||||||
"Web"
|
|
||||||
]
|
|
||||||
---
|
|
||||||
Content Page %02d
|
|
||||||
`, i, i))
|
|
||||||
}
|
|
||||||
|
|
||||||
viper.Set("paginate", 1)
|
viper.Set("paginate", 1)
|
||||||
viper.Set("title", "Hugo Rocks!")
|
viper.Set("title", "Hugo Rocks!")
|
||||||
|
@ -238,21 +223,7 @@ title = "Hugo in English"
|
||||||
`)
|
`)
|
||||||
|
|
||||||
for _, lang := range []string{"nn", "en"} {
|
for _, lang := range []string{"nn", "en"} {
|
||||||
for i := 1; i <= 4; i++ {
|
writeRegularPagesForNodeAsPageTestsWithLang(t, lang)
|
||||||
sect := "sect1"
|
|
||||||
if i > 2 {
|
|
||||||
sect = "sect2"
|
|
||||||
}
|
|
||||||
writeSource(t, filepath.Join("content", sect, fmt.Sprintf("regular%d.%s.md", i, lang)), fmt.Sprintf(`---
|
|
||||||
title: Page %02d
|
|
||||||
categories: [
|
|
||||||
"Hugo",
|
|
||||||
"Web"
|
|
||||||
]
|
|
||||||
---
|
|
||||||
Content Page %02d
|
|
||||||
`, i, i))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only write node pages for the English side of the fence
|
// Only write node pages for the English side of the fence
|
||||||
|
@ -324,6 +295,66 @@ Content Page %02d
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNodesWithTaxonomies(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 Taxonomies
|
||||||
|
categories: [
|
||||||
|
"Hugo",
|
||||||
|
"Home"
|
||||||
|
]
|
||||||
|
---
|
||||||
|
`)
|
||||||
|
|
||||||
|
viper.Set("paginate", 1)
|
||||||
|
viper.Set("title", "Hugo Rocks!")
|
||||||
|
viper.Set("rssURI", "customrss.xml")
|
||||||
|
|
||||||
|
s := newSiteDefaultLang()
|
||||||
|
|
||||||
|
if err := buildAndRenderSite(s); err != nil {
|
||||||
|
t.Fatalf("Failed to build site: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
assertFileContent(t, filepath.Join("public", "categories", "hugo", "index.html"), true, "Taxonomy Title: Hugo", "# Pages: 5", "Pag: Home With Taxonomies")
|
||||||
|
assertFileContent(t, filepath.Join("public", "categories", "home", "index.html"), true, "Taxonomy Title: Home", "# Pages: 1", "Pag: Home With Taxonomies")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func writeRegularPagesForNodeAsPageTests(t *testing.T) {
|
||||||
|
writeRegularPagesForNodeAsPageTestsWithLang(t, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
func writeRegularPagesForNodeAsPageTestsWithLang(t *testing.T, lang string) {
|
||||||
|
var langStr string
|
||||||
|
|
||||||
|
if lang != "" {
|
||||||
|
langStr = lang + "."
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := 1; i <= 4; i++ {
|
||||||
|
sect := "sect1"
|
||||||
|
if i > 2 {
|
||||||
|
sect = "sect2"
|
||||||
|
}
|
||||||
|
writeSource(t, filepath.Join("content", sect, fmt.Sprintf("regular%d.%smd", i, langStr)), fmt.Sprintf(`---
|
||||||
|
title: Page %02d
|
||||||
|
categories: [
|
||||||
|
"Hugo",
|
||||||
|
"Web"
|
||||||
|
]
|
||||||
|
---
|
||||||
|
Content Page %02d
|
||||||
|
`, i, i))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func writeNodePagesForNodeAsPageTests(lang string, t *testing.T) {
|
func writeNodePagesForNodeAsPageTests(lang string, t *testing.T) {
|
||||||
|
|
||||||
filename := "_index.md"
|
filename := "_index.md"
|
||||||
|
|
|
@ -1340,8 +1340,6 @@ func (s *Site) buildSiteMeta() (err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(bep) np order
|
|
||||||
// assembleTaxonomies: Needs pages (temp lookup) (maybe later nodes)
|
|
||||||
s.assembleTaxonomies()
|
s.assembleTaxonomies()
|
||||||
|
|
||||||
// TODO(bep) np
|
// TODO(bep) np
|
||||||
|
@ -1497,8 +1495,8 @@ func (s *Site) assembleTaxonomies() {
|
||||||
for singular, plural := range taxonomies {
|
for singular, plural := range taxonomies {
|
||||||
s.Taxonomies[plural] = make(Taxonomy)
|
s.Taxonomies[plural] = make(Taxonomy)
|
||||||
s.taxonomiesPluralSingular[plural] = singular
|
s.taxonomiesPluralSingular[plural] = singular
|
||||||
// TODO(np) tax other nodes
|
|
||||||
for _, p := range s.findPagesByNodeType(NodePage) {
|
for _, p := range s.Nodes {
|
||||||
vals := p.getParam(plural, !s.Info.preserveTaxonomyNames)
|
vals := p.getParam(plural, !s.Info.preserveTaxonomyNames)
|
||||||
weight := p.GetParam(plural + "_weight")
|
weight := p.GetParam(plural + "_weight")
|
||||||
if weight == nil {
|
if weight == nil {
|
||||||
|
|
Loading…
Reference in a new issue