shithub: hugo

Download patch

ref: eda36787429a3087a30991255f5be1576cf3e121
parent: c21e2b3b4d759bc84ba080bc35059bb51eb34144
author: Vincent Batoufflet <[email protected]>
date: Mon Jun 27 13:07:34 EDT 2016

Add automatic page date fallback

Closes #2239

--- a/hugolib/page.go
+++ b/hugolib/page.go
@@ -663,6 +663,13 @@
 		p.Draft = !*published
 	}
 
+	if p.Date.IsZero() {
+		fi, err := hugofs.Source().Stat(filepath.Join(helpers.AbsPathify(viper.GetString("ContentDir")), p.File.Path()))
+		if err == nil {
+			p.Date = fi.ModTime()
+		}
+	}
+
 	if p.Lastmod.IsZero() {
 		p.Lastmod = p.Date
 	}