diff options
author | Brian Chen <brian.chxn@gmail.com> | 2017-11-06 22:58:41 -0500 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-11-07 23:05:48 +0100 |
commit | d9a78b61adefe8e1803529f4774185874af85148 (patch) | |
tree | e53d6e6a8b5588a99a30632ce355c1df34d2e043 /hugolib/taxonomy_test.go | |
parent | 23ba779fab90ce45cddd68b4f49a2515ce6d4878 (diff) |
Handle Taxonomy permalinks
Return the correct virtual Section for Taxonomy and TaxonomyTerm.
Restrict permalink expansion to only Pages and Taxonomies, but then
actually use expanded permalinks even for non-Pages.
Fixes #1208.
Diffstat (limited to 'hugolib/taxonomy_test.go')
-rw-r--r-- | hugolib/taxonomy_test.go | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/hugolib/taxonomy_test.go b/hugolib/taxonomy_test.go index 4f8717d72..bbde9354d 100644 --- a/hugolib/taxonomy_test.go +++ b/hugolib/taxonomy_test.go @@ -77,6 +77,10 @@ tag = "tags" category = "categories" other = "others" empty = "empties" +permalinked = "permalinkeds" + +[permalinks] +permalinkeds = "/perma/:slug/" ` pageTemplate := `--- @@ -87,6 +91,8 @@ categories: %s others: %s +permalinkeds: +%s --- # Doc ` @@ -99,15 +105,15 @@ others: fs := th.Fs if preserveTaxonomyNames { - writeSource(t, fs, "content/p1.md", fmt.Sprintf(pageTemplate, "t1/c1", "- tag1", "- cat1", "- o1")) + writeSource(t, fs, "content/p1.md", fmt.Sprintf(pageTemplate, "t1/c1", "- tag1", "- cat1", "- o1", "- pl1")) } else { // Check lower-casing of tags - writeSource(t, fs, "content/p1.md", fmt.Sprintf(pageTemplate, "t1/c1", "- Tag1", "- cAt1", "- o1")) + writeSource(t, fs, "content/p1.md", fmt.Sprintf(pageTemplate, "t1/c1", "- Tag1", "- cAt1", "- o1", "- pl1")) } - writeSource(t, fs, "content/p2.md", fmt.Sprintf(pageTemplate, "t2/c1", "- tag2", "- cat1", "- o1")) - writeSource(t, fs, "content/p3.md", fmt.Sprintf(pageTemplate, "t2/c12", "- tag2", "- cat2", "- o1")) - writeSource(t, fs, "content/p4.md", fmt.Sprintf(pageTemplate, "Hello World", "", "", "- \"Hello Hugo world\"")) + writeSource(t, fs, "content/p2.md", fmt.Sprintf(pageTemplate, "t2/c1", "- tag2", "- cat1", "- o1", "- pl1")) + writeSource(t, fs, "content/p3.md", fmt.Sprintf(pageTemplate, "t2/c12", "- tag2", "- cat2", "- o1", "- pl1")) + writeSource(t, fs, "content/p4.md", fmt.Sprintf(pageTemplate, "Hello World", "", "", "- \"Hello Hugo world\"", "- pl1")) writeNewContentFile(t, fs, "Category Terms", "2017-01-01", "content/categories/_index.md", 10) writeNewContentFile(t, fs, "Tag1 List", "2017-01-01", "content/tags/tag1/_index.md", 10) @@ -146,10 +152,11 @@ others: // Make sure that each KindTaxonomyTerm page has an appropriate number // of KindTaxonomy pages in its Pages slice. taxonomyTermPageCounts := map[string]int{ - "tags": 2, - "categories": 2, - "others": 2, - "empties": 0, + "tags": 2, + "categories": 2, + "others": 2, + "empties": 0, + "permalinkeds": 1, } for taxonomy, count := range taxonomyTermPageCounts { @@ -170,6 +177,14 @@ others: require.Equal(t, "/blog/categories/cat1/", cat1.RelPermalink()) } + pl1 := s.getPage(KindTaxonomy, "permalinkeds", "pl1") + require.NotNil(t, pl1) + if uglyURLs { + require.Equal(t, "/blog/perma/pl1.html", pl1.RelPermalink()) + } else { + require.Equal(t, "/blog/perma/pl1/", pl1.RelPermalink()) + } + // Issue #3070 preserveTaxonomyNames if preserveTaxonomyNames { helloWorld := s.getPage(KindTaxonomy, "others", "Hello Hugo world") |