summaryrefslogtreecommitdiffstats
path: root/hugolib
diff options
context:
space:
mode:
authorJeff Hodges <jeff@somethingsimilar.com>2015-08-30 15:51:25 -0700
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2015-08-31 05:26:46 +0200
commit49fe04c0bd8111bf686d9205d543f8651ea24cfc (patch)
treec6e4c9a4addbbf99617d0fc5c4e84e48de793be2 /hugolib
parent311593bff013d5b99c68f498861ffde810be71b1 (diff)
Correct check of published boolean
Diffstat (limited to 'hugolib')
-rw-r--r--hugolib/page.go2
-rw-r--r--hugolib/page_test.go30
2 files changed, 31 insertions, 1 deletions
diff --git a/hugolib/page.go b/hugolib/page.go
index f281053a2..b80e92257 100644
--- a/hugolib/page.go
+++ b/hugolib/page.go
@@ -514,7 +514,7 @@ func (p *Page) update(f interface{}) error {
*draft = cast.ToBool(v)
case "published": // Intentionally undocumented
published = new(bool)
- *published = !cast.ToBool(v)
+ *published = cast.ToBool(v)
case "layout":
p.layout = cast.ToString(v)
case "markup":
diff --git a/hugolib/page_test.go b/hugolib/page_test.go
index 7a9c12321..9a1b67fa1 100644
--- a/hugolib/page_test.go
+++ b/hugolib/page_test.go
@@ -869,6 +869,36 @@ func TestDraftAndPublishedFrontMatterError(t *testing.T) {
}
}
+var PAGE_WITH_PUBLISHED_FALSE = `---
+title: okay
+published: false
+---
+some content
+`
+var PAGE_WITH_PUBLISHED_TRUE = `---
+title: okay
+published: true
+---
+some content
+`
+
+func TestPublishedFrontMatter(t *testing.T) {
+ p, err := NewPageFrom(strings.NewReader(PAGE_WITH_PUBLISHED_FALSE), "content/post/broken.md")
+ if err != nil {
+ t.Fatalf("err during parse: %s", err)
+ }
+ if !p.Draft {
+ t.Errorf("expected true, got %t", p.Draft)
+ }
+ p, err = NewPageFrom(strings.NewReader(PAGE_WITH_PUBLISHED_TRUE), "content/post/broken.md")
+ if err != nil {
+ t.Fatalf("err during parse: %s", err)
+ }
+ if p.Draft {
+ t.Errorf("expected false, got %t", p.Draft)
+ }
+}
+
func listEqual(left, right []string) bool {
if len(left) != len(right) {
return false