mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
parent
bd0200da6e
commit
146aedd7aa
2 changed files with 25 additions and 3 deletions
|
@ -1859,13 +1859,12 @@ func (m *pageMap) CreateSiteTaxonomies(ctx context.Context) error {
|
||||||
LockType: doctree.LockTypeRead,
|
LockType: doctree.LockTypeRead,
|
||||||
Handle: func(s string, n contentNodeI, match doctree.DimensionFlag) (bool, error) {
|
Handle: func(s string, n contentNodeI, match doctree.DimensionFlag) (bool, error) {
|
||||||
p := n.(*pageState)
|
p := n.(*pageState)
|
||||||
plural := p.Section()
|
|
||||||
|
|
||||||
switch p.Kind() {
|
switch p.Kind() {
|
||||||
case kinds.KindTerm:
|
case kinds.KindTerm:
|
||||||
taxonomy := m.s.taxonomies[plural]
|
taxonomy := m.s.taxonomies[viewName.plural]
|
||||||
if taxonomy == nil {
|
if taxonomy == nil {
|
||||||
return true, fmt.Errorf("missing taxonomy: %s", plural)
|
return true, fmt.Errorf("missing taxonomy: %s", viewName.plural)
|
||||||
}
|
}
|
||||||
k := strings.ToLower(p.m.term)
|
k := strings.ToLower(p.m.term)
|
||||||
err := m.treeTaxonomyEntries.WalkPrefix(
|
err := m.treeTaxonomyEntries.WalkPrefix(
|
||||||
|
|
|
@ -753,3 +753,26 @@ Single.
|
||||||
`
|
`
|
||||||
Test(t, files)
|
Test(t, files)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestTaxonomiesSpaceInName(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
files := `
|
||||||
|
-- hugo.toml --
|
||||||
|
[taxonomies]
|
||||||
|
authors = 'book authors'
|
||||||
|
-- content/p1.md --
|
||||||
|
---
|
||||||
|
title: Good Omens
|
||||||
|
book authors:
|
||||||
|
- Neil Gaiman
|
||||||
|
- Terry Pratchett
|
||||||
|
---
|
||||||
|
-- layouts/index.html --
|
||||||
|
{{- $taxonomy := "book authors" }}
|
||||||
|
Len Book Authors: {{ len (index .Site.Taxonomies $taxonomy) }}
|
||||||
|
`
|
||||||
|
b := Test(t, files)
|
||||||
|
|
||||||
|
b.AssertFileContent("public/index.html", "Len Book Authors: 2")
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue