shithub: hugo

Download patch

ref: bc3c2290027359206f3569bcd51447443f7b40bb
parent: c32f401b15ee09ed9ccb4af1d517852f41e9c804
author: Noah Campbell <[email protected]>
date: Fri Aug 30 13:14:36 EDT 2013

Ensure Section is set before returning Page object.

--- a/hugolib/page.go
+++ b/hugolib/page.go
@@ -87,6 +87,7 @@
 		Params: make(map[string]interface{}),
 		Markup: "md"}
 	page.Date, _ = time.Parse("20060102", "20080101")
+	page.guessSection()
 	return &page
 }
 
--- a/hugolib/page_test.go
+++ b/hugolib/page_test.go
@@ -219,6 +219,13 @@
 	}
 }
 
+func TestSectionEvaluation(t *testing.T) {
+	page, _ := ReadFrom(strings.NewReader(SIMPLE_PAGE), filepath.FromSlash("blue/file1.md"))
+	if page.Section != "blue" {
+		t.Errorf("Section should be %s, got: %s", "blue", page.Section)
+	}
+}
+
 func TestLayoutOverride(t *testing.T) {
 	var (
 		path_content_one_dir = filepath.Join("content", "gub", "file1.md")