Add automatic page date fallback

Closes #2239
This commit is contained in:
Vincent Batoufflet authored and Bjørn Erik Pedersen committed 2016-06-28 23:50:50 +02:00
1 parent c21e2b3b4d
commit eda3678742
1 file changed
+7
+7
View File
@@ -663,6 +663,13 @@ func (p *Page) update(f interface{}) error {
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
}