Fix GetTerms nil pointer

Fixes #7061
This commit is contained in:
Carl Johnson 2020-03-20 09:35:41 -04:00 committed by GitHub
parent c947351d7c
commit 95f492114e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View file

@ -141,7 +141,7 @@ func (p *pageState) GetTerms(taxonomy string) page.Pages {
if p.IsHome() { if p.IsHome() {
// TODO(bep) make this less magical, see taxonomyEntries.Insert. // TODO(bep) make this less magical, see taxonomyEntries.Insert.
self = "/" + page.KindHome self = "/" + page.KindHome
} else { } else if p.treeRef != nil {
self = p.treeRef.key self = p.treeRef.key
} }

View file

@ -625,7 +625,9 @@ Category Paginator {{ range $categories.Paginator.Pages }}{{ .RelPermalink }}|{{
Cats Paginator {{ range $cats.Paginator.Pages }}{{ .RelPermalink }}|{{ end }}:END Cats Paginator {{ range $cats.Paginator.Pages }}{{ .RelPermalink }}|{{ end }}:END
`) `)
b.WithTemplatesAdded("404.html", `
404 Terms: {{ range .GetTerms "categories" }}{{.RelPermalink }}|{{ end }}:END
`)
b.Build(BuildCfg{}) b.Build(BuildCfg{})
cat := b.GetPage("categories") cat := b.GetPage("categories")
@ -647,7 +649,7 @@ Home Terms: /categories/dogs/|/categories/gorillas/|:END
Cats Paginator /section/p1/|/section/|:END Cats Paginator /section/p1/|/section/|:END
Category Paginator /categories/birds/|/categories/cats/|/categories/dogs/|/categories/funny/|/categories/gorillas/|:END Category Paginator /categories/birds/|/categories/cats/|/categories/dogs/|/categories/funny/|/categories/gorillas/|:END
`) `)
b.AssertFileContent("public/404.html", "\n404 Terms: :END\n\t")
b.AssertFileContent("public/categories/funny/index.xml", `<link>http://example.com/section/p1/</link>`) b.AssertFileContent("public/categories/funny/index.xml", `<link>http://example.com/section/p1/</link>`)
b.AssertFileContent("public/categories/index.xml", `<link>http://example.com/categories/funny/</link>`) b.AssertFileContent("public/categories/index.xml", `<link>http://example.com/categories/funny/</link>`)