Skip to content

Commit

Permalink
Fix panic with empty taxonomy param
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed Jan 17, 2024
1 parent e287ead commit 691d7bc
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
3 changes: 3 additions & 0 deletions hugolib/content_map_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -1315,6 +1315,9 @@ func (sa *sitePagesAssembler) assembleTermsAndTranslations() error {
}

for i, v := range vals {
if v == "" {
continue
}
viewTermKey := "/" + viewName.plural + "/" + v
pi := sa.Site.Conf.PathParser().Parse(files.ComponentFolderContent, viewTermKey+"/_index.md")
term := pages.Get(pi.Base())
Expand Down
24 changes: 24 additions & 0 deletions hugolib/pagecollections_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,30 @@ title: p2
b.AssertFileContent("public/s1/p2/index.html", "OK: p2")
}

func TestGetPageBundleToRegular2(t *testing.T) {
files := `
-- hugo.toml --
-- content/s1/p1/index.md --
---
title: p1
---
-- content/s1/p2.md --
---
title: p2
---
-- content/p2.md --
---
title: p2_root
---
-- layouts/_default/single.html --
../p2: {{ with .GetPage "../p2" }}{{ .Title }}{{ end }}|
`

b := Test(t, files)
b.AssertFileContent("public/s1/p1/index.html", "../p2: p2_root|")
b.AssertFileContent("public/s1/p1/index.html", "../p2: p2_root|")
}

// https://github.com/gohugoio/hugo/issues/7016
func TestGetPageMultilingual(t *testing.T) {
b := newTestSitesBuilder(t)
Expand Down
19 changes: 19 additions & 0 deletions hugolib/taxonomy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -739,3 +739,22 @@ tags_weight: 40

b.AssertFileContent("public/index.html", `:/p1/|/p3/|/p2/|:`)
}

func TestTaxonomiesEmptyTagsString(t *testing.T) {
t.Parallel()

files := `
-- hugo.toml --
[taxonomies]
tag = 'tags'
-- content/p1.md --
+++
title = "P1"
tags = ''
+++
-- layouts/_default/single.html --
Single.
`
Test(t, files)
}

0 comments on commit 691d7bc

Please sign in to comment.