Skip to content

Commit

Permalink
Add Sections to Site interface
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed May 16, 2023
1 parent 3d90871 commit faa6998
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
27 changes: 27 additions & 0 deletions hugolib/config_test.go
Expand Up @@ -741,3 +741,30 @@ themeconfigdirparam: {{ site.Params.themeconfigdirparam }}
}

}

// TODO(beo) find a better place for this.
func TestReproCommentsIn10947(t *testing.T) {
t.Parallel()

files := `
-- hugo.toml --
baseURL = "https://example.com"
-- content/mysection/_index.md --
---
title: "My Section"
---
-- layouts/index.html --
Sections: {{ if site.Sections }}true{{ end }}|
`
b := NewIntegrationTestBuilder(
IntegrationTestConfig{
T: t,
TxtarString: files,
},
).Build()

b.AssertFileContent("public/index.html", "Sections: true|")

}
11 changes: 11 additions & 0 deletions resources/page/site.go
Expand Up @@ -43,6 +43,9 @@ type Site interface {
// Returns all Pages in this Site.
Pages() Pages

// Returns all the top level sections.
Sections() Pages

// A shortcut to the home
Home() Page

Expand Down Expand Up @@ -164,6 +167,10 @@ func (s *siteWrapper) Pages() Pages {
return s.s.Pages()
}

func (s *siteWrapper) Sections() Pages {
return s.s.Sections()
}

func (s *siteWrapper) Home() Page {
return s.s.Home()
}
Expand Down Expand Up @@ -285,6 +292,10 @@ func (t testSite) Sites() Sites {
return nil
}

func (t testSite) Sections() Pages {
return nil
}

func (t testSite) GetPage(ref ...string) (Page, error) {
return nil, nil
}
Expand Down

0 comments on commit faa6998

Please sign in to comment.