shithub: hugo

Download patch

ref: ef03c6f95412494902aef40335d8666136fad558
parent: e4ebe0d5bf9d25d7e30acd6fc18610d96abb3d6f
author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
date: Thu Dec 15 04:27:30 EST 2016

create: Allow empty dates in archetype in new

To make it behave the same as Hugo 0.17.

--- a/create/content.go
+++ b/create/content.go
@@ -110,6 +110,9 @@
 	var date time.Time
 
 	for k, v := range metadata {
+		if v == "" {
+			continue
+		}
 		lk := strings.ToLower(k)
 		switch lk {
 		case "date":
--- a/create/content_test.go
+++ b/create/content_test.go
@@ -42,6 +42,7 @@
 		expected []string
 	}{
 		{"post", "post/sample-1.md", []string{`title = "Post Arch title"`, `test = "test1"`, "date = \"2015-01-12T19:20:04-07:00\""}},
+		{"emptydate", "post/sample-ed.md", []string{`title = "Empty Date Arch title"`, `test = "test1"`}},
 		{"stump", "stump/sample-2.md", []string{`title = "sample 2"`}},     // no archetype file
 		{"", "sample-3.md", []string{`title = "sample 3"`}},                // no archetype
 		{"product", "product/sample-4.md", []string{`title = "sample 4"`}}, // empty archetype front matter
@@ -104,6 +105,10 @@
 		{
 			path:    filepath.Join("archetypes", "product.md"),
 			content: "+++\n+++\n",
+		},
+		{
+			path:    filepath.Join("archetypes", "emptydate.md"),
+			content: "+++\ndate =\"\"\ntitle = \"Empty Date Arch title\"\ntest = \"test1\"\n+++\n",
 		},
 	} {
 		f, err := hugofs.Source().Create(v.path)
--