aboutsummaryrefslogtreecommitdiffhomepage
path: root/hugolib/taxonomy_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2020-02-19 09:16:27 +0100
committerBjørn Erik Pedersen <[email protected]>2020-02-19 14:52:23 +0100
commitfa520a2d983b982394ad10088393fb303e48980a (patch)
treef545a33ef8de2eccc6fe781281126a5daf90a4c0 /hugolib/taxonomy_test.go
parent82029c1ec975bc2173bd5a454aee6c800924035d (diff)
downloadhugo-fa520a2d983b982394ad10088393fb303e48980a.tar.gz
hugo-fa520a2d983b982394ad10088393fb303e48980a.zip
Add Page.GetTerms
Fixes #6905
Diffstat (limited to 'hugolib/taxonomy_test.go')
-rw-r--r--hugolib/taxonomy_test.go33
1 files changed, 26 insertions, 7 deletions
diff --git a/hugolib/taxonomy_test.go b/hugolib/taxonomy_test.go
index d91e7699f..913773da6 100644
--- a/hugolib/taxonomy_test.go
+++ b/hugolib/taxonomy_test.go
@@ -542,25 +542,41 @@ func TestTaxonomiesPageCollections(t *testing.T) {
t.Parallel()
b := newTestSitesBuilder(t)
- b.WithContent("p1.md", `---
+ b.WithContent(
+ "_index.md", `---
+title: "Home Sweet Home"
+categories: [ "dogs", "gorillas"]
+---
+`,
+ "section/_index.md", `---
+title: "Section"
+categories: [ "cats", "dogs", "birds"]
+---
+`,
+ "section/p1.md", `---
title: "Page1"
categories: ["funny", "cats"]
---
-`, "p2.md", `---
+`, "section/p2.md", `---
title: "Page2"
categories: ["funny"]
---
`)
b.WithTemplatesAdded("index.html", `
+{{ $home := site.Home }}
+{{ $section := site.GetPage "section" }}
{{ $categories := site.GetPage "categories" }}
{{ $funny := site.GetPage "categories/funny" }}
{{ $cats := site.GetPage "categories/cats" }}
+{{ $p1 := site.GetPage "section/p1" }}
Categories Pages: {{ range $categories.Pages}}{{.RelPermalink }}|{{ end }}:END
Funny Pages: {{ range $funny.Pages}}{{.RelPermalink }}|{{ end }}:END
Cats Pages: {{ range $cats.Pages}}{{.RelPermalink }}|{{ end }}:END
-
+P1 Terms: {{ range $p1.GetTerms "categories" }}{{.RelPermalink }}|{{ end }}:END
+Section Terms: {{ range $section.GetTerms "categories" }}{{.RelPermalink }}|{{ end }}:END
+Home Terms: {{ range $home.GetTerms "categories" }}{{.RelPermalink }}|{{ end }}:END
`)
b.Build(BuildCfg{})
@@ -575,12 +591,15 @@ Cats Pages: {{ range $cats.Pages}}{{.RelPermalink }}|{{ end }}:END
b.Assert(funny.Parent(), qt.Equals, cat)
b.AssertFileContent("public/index.html", `
-Categories Pages: /categories/cats/|/categories/funny/|:END
-Funny Pages: /p1/|/p2/|:END
-Cats Pages: /p1/|:END
+ Categories Pages: /categories/birds/|/categories/cats/|/categories/dogs/|/categories/funny/|/categories/gorillas/|:END
+ Funny Pages: /section/p1/|/section/p2/|:END
+ Cats Pages: /section/p1/|/section/|:END
+ P1 Terms: /categories/cats/|/categories/funny/|:END
+ Section Terms: /categories/birds/|/categories/cats/|/categories/dogs/|:END
+ Home Terms: /categories/dogs/|/categories/gorillas/|:END
`)
- b.AssertFileContent("public/categories/funny/index.xml", `<link>http://example.com/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>`)
}