mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
parent
38f68cd162
commit
a6e8439176
2 changed files with 34 additions and 0 deletions
|
@ -112,6 +112,14 @@ func (i Taxonomy) ByCount() OrderedTaxonomy {
|
|||
return ia
|
||||
}
|
||||
|
||||
// Page returns the taxonomy page or nil if the taxonomy has no terms.
|
||||
func (i Taxonomy) Page() Page {
|
||||
for _, v := range i {
|
||||
return v.Page().Parent()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Pages returns the Pages for this taxonomy.
|
||||
func (ie OrderedTaxonomyEntry) Pages() Pages {
|
||||
return ie.WeightedPages.Pages()
|
||||
|
|
|
@ -53,3 +53,29 @@ authors: [John Smith]
|
|||
"Robert Jones count: 1",
|
||||
)
|
||||
}
|
||||
|
||||
func TestTaxonomiesPage(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- hugo.toml --
|
||||
disableKinds = ['rss','section','sitemap']
|
||||
[taxonomies]
|
||||
tag = 'tags'
|
||||
category = 'categories'
|
||||
-- content/p1.md --
|
||||
---
|
||||
title: p1
|
||||
tags: [tag-a]
|
||||
---
|
||||
-- layouts/_default/list.html --
|
||||
{{- with site.Taxonomies.tags.Page }}{{ .RelPermalink }}{{ end }}|
|
||||
{{- with site.Taxonomies.categories.Page }}{{ .RelPermalink }}{{ end }}|
|
||||
-- layouts/_default/single.html --
|
||||
{{ .Title }}
|
||||
`
|
||||
|
||||
b := hugolib.Test(t, files)
|
||||
|
||||
b.AssertFileContent("public/index.html", "/tags/||")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue