summaryrefslogtreecommitdiffstats
path: root/hugolib/disableKinds_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-02-21 09:02:07 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2020-02-21 09:41:39 +0100
commitf46053034759c4f9790a79e0a146dbc1b426b1ff (patch)
tree8162b999e444b887f104ffdf1ae700352860bccb /hugolib/disableKinds_test.go
parent4c2a0de412a850745ad32e580fcd65575192ca53 (diff)
Fix panic on no output formats
A page needs its output formats even if it should not be rendered or its resources should not be published. Fixes #6924
Diffstat (limited to 'hugolib/disableKinds_test.go')
-rw-r--r--hugolib/disableKinds_test.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/hugolib/disableKinds_test.go b/hugolib/disableKinds_test.go
index 3d78e29f3..b1c00b48e 100644
--- a/hugolib/disableKinds_test.go
+++ b/hugolib/disableKinds_test.go
@@ -311,3 +311,37 @@ _build:
b.Assert(b.CheckExists("public/section/bundle-false/data2.json"), qt.Equals, false)
b.AssertFileContent("public/section/bundle-true/data3.json", `Some data 3`)
}
+
+func TestNoRenderAndNoPublishResources(t *testing.T) {
+ noRenderPage := `
+---
+title: %s
+_build:
+ render: false
+ publishResources: false
+---
+`
+ b := newTestSitesBuilder(t)
+ b.WithTemplatesAdded("index.html", `
+{{ $page := site.GetPage "sect/no-render" }}
+{{ $sect := site.GetPage "sect-no-render" }}
+
+Page: {{ $page.Title }}|RelPermalink: {{ $page.RelPermalink }}|Outputs: {{ len $page.OutputFormats }}
+Section: {{ $sect.Title }}|RelPermalink: {{ $sect.RelPermalink }}|Outputs: {{ len $sect.OutputFormats }}
+
+
+`)
+ b.WithContent("sect-no-render/_index.md", fmt.Sprintf(noRenderPage, "MySection"))
+ b.WithContent("sect/no-render.md", fmt.Sprintf(noRenderPage, "MyPage"))
+
+ b.Build(BuildCfg{})
+
+ b.AssertFileContent("public/index.html", `
+Page: MyPage|RelPermalink: |Outputs: 0
+Section: MySection|RelPermalink: |Outputs: 0
+`)
+
+ b.Assert(b.CheckExists("public/sect/no-render/index.html"), qt.Equals, false)
+ b.Assert(b.CheckExists("public/sect-no-render/index.html"), qt.Equals, false)
+
+}