mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
Add Sections to Site interface
See https://github.com/gohugoio/hugo/issues/10947#issuecomment-1550012671 Updates #10947
This commit is contained in:
parent
3d90871e9e
commit
faa6998f26
2 changed files with 38 additions and 0 deletions
|
@ -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|")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -43,6 +43,9 @@ type Site interface {
|
||||||
// Returns all Pages in this Site.
|
// Returns all Pages in this Site.
|
||||||
Pages() Pages
|
Pages() Pages
|
||||||
|
|
||||||
|
// Returns all the top level sections.
|
||||||
|
Sections() Pages
|
||||||
|
|
||||||
// A shortcut to the home
|
// A shortcut to the home
|
||||||
Home() Page
|
Home() Page
|
||||||
|
|
||||||
|
@ -164,6 +167,10 @@ func (s *siteWrapper) Pages() Pages {
|
||||||
return s.s.Pages()
|
return s.s.Pages()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *siteWrapper) Sections() Pages {
|
||||||
|
return s.s.Sections()
|
||||||
|
}
|
||||||
|
|
||||||
func (s *siteWrapper) Home() Page {
|
func (s *siteWrapper) Home() Page {
|
||||||
return s.s.Home()
|
return s.s.Home()
|
||||||
}
|
}
|
||||||
|
@ -285,6 +292,10 @@ func (t testSite) Sites() Sites {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t testSite) Sections() Pages {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (t testSite) GetPage(ref ...string) (Page, error) {
|
func (t testSite) GetPage(ref ...string) (Page, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue