]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
Add Sections to Site interface
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 16 May 2023 16:53:34 +0000 (18:53 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 16 May 2023 16:53:34 +0000 (18:53 +0200)
See https://github.com/gohugoio/hugo/issues/10947#issuecomment-1550012671

Updates #10947

hugolib/config_test.go
resources/page/site.go

index 169674acbb9e338435b6e7a2b51439f3bec97998..aa7785f929c423ff87fac65f32753c6060bda1e1 100644 (file)
@@ -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|")
+
+}
index 3243e9b39be753bddd9018df5e6a565f86fc1016..67b15cd8a3e31b345b4dadf8d6e7b1c7fff0d505 100644 (file)
@@ -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
 
@@ -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()
 }
@@ -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
 }