parent
eb298144b6
commit
e917401c71
3 changed files with 51 additions and 8 deletions
|
@ -1595,6 +1595,10 @@ func (sa *sitePagesAssembler) applyAggregatesToTaxonomiesAndTerms() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sa *sitePagesAssembler) assembleTermsAndTranslations() error {
|
func (sa *sitePagesAssembler) assembleTermsAndTranslations() error {
|
||||||
|
if sa.pageMap.cfg.taxonomyTermDisabled {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
pages = sa.pageMap.treePages
|
pages = sa.pageMap.treePages
|
||||||
entries = sa.pageMap.treeTaxonomyEntries
|
entries = sa.pageMap.treeTaxonomyEntries
|
||||||
|
@ -1612,10 +1616,6 @@ func (sa *sitePagesAssembler) assembleTermsAndTranslations() error {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if sa.pageMap.cfg.taxonomyTermDisabled {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, viewName := range views {
|
for _, viewName := range views {
|
||||||
vals := types.ToStringSlicePreserveString(getParam(ps, viewName.plural, false))
|
vals := types.ToStringSlicePreserveString(getParam(ps, viewName.plural, false))
|
||||||
if vals == nil {
|
if vals == nil {
|
||||||
|
@ -1674,6 +1674,7 @@ func (sa *sitePagesAssembler) assembleTermsAndTranslations() error {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false, nil
|
return false, nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ package hugolib
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
|
@ -140,6 +141,7 @@ func (h *HugoSites) doNewPage(m *pageMeta) (*pageState, *paths.Path, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var tc viewName
|
||||||
// Identify Page Kind.
|
// Identify Page Kind.
|
||||||
if m.pageConfig.Kind == "" {
|
if m.pageConfig.Kind == "" {
|
||||||
m.pageConfig.Kind = kinds.KindSection
|
m.pageConfig.Kind = kinds.KindSection
|
||||||
|
@ -147,16 +149,13 @@ func (h *HugoSites) doNewPage(m *pageMeta) (*pageState, *paths.Path, error) {
|
||||||
m.pageConfig.Kind = kinds.KindHome
|
m.pageConfig.Kind = kinds.KindHome
|
||||||
} else if m.pathInfo.IsBranchBundle() {
|
} else if m.pathInfo.IsBranchBundle() {
|
||||||
// A section, taxonomy or term.
|
// A section, taxonomy or term.
|
||||||
tc := m.s.pageMap.cfg.getTaxonomyConfig(m.Path())
|
tc = m.s.pageMap.cfg.getTaxonomyConfig(m.Path())
|
||||||
if !tc.IsZero() {
|
if !tc.IsZero() {
|
||||||
// Either a taxonomy or a term.
|
// Either a taxonomy or a term.
|
||||||
if tc.pluralTreeKey == m.Path() {
|
if tc.pluralTreeKey == m.Path() {
|
||||||
m.pageConfig.Kind = kinds.KindTaxonomy
|
m.pageConfig.Kind = kinds.KindTaxonomy
|
||||||
m.singular = tc.singular
|
|
||||||
} else {
|
} else {
|
||||||
m.pageConfig.Kind = kinds.KindTerm
|
m.pageConfig.Kind = kinds.KindTerm
|
||||||
m.term = m.pathInfo.Unnormalized().BaseNameNoIdentifier()
|
|
||||||
m.singular = tc.singular
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if m.f != nil {
|
} else if m.f != nil {
|
||||||
|
@ -164,6 +163,19 @@ func (h *HugoSites) doNewPage(m *pageMeta) (*pageState, *paths.Path, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if m.pageConfig.Kind == kinds.KindTerm || m.pageConfig.Kind == kinds.KindTaxonomy {
|
||||||
|
if tc.IsZero() {
|
||||||
|
tc = m.s.pageMap.cfg.getTaxonomyConfig(m.Path())
|
||||||
|
}
|
||||||
|
if tc.IsZero() {
|
||||||
|
return nil, fmt.Errorf("no taxonomy configuration found for %q", m.Path())
|
||||||
|
}
|
||||||
|
m.singular = tc.singular
|
||||||
|
if m.pageConfig.Kind == kinds.KindTerm {
|
||||||
|
m.term = paths.TrimLeading(strings.TrimPrefix(m.pathInfo.Unnormalized().Base(), tc.pluralTreeKey))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if m.pageConfig.Kind == kinds.KindPage && !m.s.conf.IsKindEnabled(m.pageConfig.Kind) {
|
if m.pageConfig.Kind == kinds.KindPage && !m.s.conf.IsKindEnabled(m.pageConfig.Kind) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -678,3 +678,33 @@ summary: {{ .Summary }}|content: {{ .Content}}
|
||||||
"<p>aaa</p>|content: <p>aaa</p>\n<p>bbb</p>",
|
"<p>aaa</p>|content: <p>aaa</p>\n<p>bbb</p>",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Issue 13063.
|
||||||
|
func TestPagesFromGoTmplTermIsEmpty(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
files := `
|
||||||
|
-- hugo.toml --
|
||||||
|
baseURL = "https://example.com"
|
||||||
|
disableKinds = ['section', 'home', 'rss','sitemap']
|
||||||
|
printPathWarnings = true
|
||||||
|
[taxonomies]
|
||||||
|
tag = "tags"
|
||||||
|
-- content/mypost.md --
|
||||||
|
---
|
||||||
|
title: "My Post"
|
||||||
|
tags: ["mytag"]
|
||||||
|
---
|
||||||
|
-- content/tags/_content.gotmpl --
|
||||||
|
{{ .AddPage (dict "path" "mothertag" "title" "My title" "kind" "term") }}
|
||||||
|
--
|
||||||
|
-- layouts/_default/taxonomy.html --
|
||||||
|
Terms: {{ range .Data.Terms.ByCount }}{{ .Name }}: {{ .Count }}|{{ end }}§s
|
||||||
|
-- layouts/_default/single.html --
|
||||||
|
Single.
|
||||||
|
`
|
||||||
|
|
||||||
|
b := hugolib.Test(t, files, hugolib.TestOptWarn())
|
||||||
|
|
||||||
|
b.AssertFileContent("public/tags/index.html", "Terms: mytag: 1|§s")
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue