diff options
Diffstat (limited to 'hugolib')
-rw-r--r-- | hugolib/content_map.go | 9 | ||||
-rw-r--r-- | hugolib/integrationtest_builder.go | 4 | ||||
-rw-r--r-- | hugolib/page__paths.go | 4 | ||||
-rw-r--r-- | hugolib/site_url_test.go | 22 |
4 files changed, 36 insertions, 3 deletions
diff --git a/hugolib/content_map.go b/hugolib/content_map.go index a7f344004..9abf0d5b0 100644 --- a/hugolib/content_map.go +++ b/hugolib/content_map.go @@ -680,7 +680,14 @@ func (m *contentMap) splitKey(k string) []string { return nil } - return strings.Split(k, "/")[1:] + parts := strings.Split(k, "/")[1:] + if len(parts) == 0 { + return nil + } + if parts[len(parts)-1] == "" { + parts = parts[:len(parts)-1] + } + return parts } func (m *contentMap) testDump() string { diff --git a/hugolib/integrationtest_builder.go b/hugolib/integrationtest_builder.go index 9c40fa7d0..3910e2b97 100644 --- a/hugolib/integrationtest_builder.go +++ b/hugolib/integrationtest_builder.go @@ -205,6 +205,10 @@ func (s *IntegrationTestBuilder) Build() *IntegrationTestBuilder { return s } +func (s *IntegrationTestBuilder) LogString() string { + return s.logBuff.String() +} + func (s *IntegrationTestBuilder) BuildE() (*IntegrationTestBuilder, error) { s.Helper() if err := s.initBuilder(); err != nil { diff --git a/hugolib/page__paths.go b/hugolib/page__paths.go index f98531c10..a834a1d9d 100644 --- a/hugolib/page__paths.go +++ b/hugolib/page__paths.go @@ -109,13 +109,13 @@ func createTargetPathDescriptor(s *Site, p page.Page, pm *pageMeta) (page.Target ) d := s.Deps - classifier := files.ContentClassZero + var classifier files.ContentClass if !p.File().IsZero() { dir = p.File().Dir() baseName = p.File().TranslationBaseName() contentBaseName = p.File().ContentBaseName() - classifier = p.File().Classifier() + classifier = p.File().FileInfo().Meta().Classifier } if classifier == files.ContentClassLeaf { diff --git a/hugolib/site_url_test.go b/hugolib/site_url_test.go index 62483093c..cb69be4ca 100644 --- a/hugolib/site_url_test.go +++ b/hugolib/site_url_test.go @@ -160,3 +160,25 @@ Do not go gentle into that good night. th.assertFileContent(filepath.Join("public", "ss1", "index.html"), "P1|URL: /ss1/|Next: /ss1/page/2/") th.assertFileContent(filepath.Join("public", "ss1", "page", "2", "index.html"), "P2|URL: /ss1/page/2/|Next: /ss1/page/3/") } + +func TestSectionsEntries(t *testing.T) { + files := ` +-- hugo.toml -- +-- content/withfile/_index.md -- +-- content/withoutfile/p1.md -- +-- layouts/_default/list.html -- +SectionsEntries: {{ .SectionsEntries }} + + +` + + b := NewIntegrationTestBuilder( + IntegrationTestConfig{ + T: t, + TxtarString: files, + }, + ).Build() + + b.AssertFileContent("public/withfile/index.html", "SectionsEntries: [withfile]") + b.AssertFileContent("public/withoutfile/index.html", "SectionsEntries: [withoutfile]") +} |