mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-20 21:31:32 +02:00
Add Lastmod field
Create new field in Node Update Page to look for lastmod field in the front matter. If not present, then assign Date to Lastmod Update Site, to assign a value to Lastmod (based on the same logic used for Date) Fixes #733
This commit is contained in:
@@ -473,6 +473,11 @@ func (p *Page) update(f interface{}) error {
|
||||
if err != nil {
|
||||
jww.ERROR.Printf("Failed to parse date '%v' in page %s", v, p.File.Path())
|
||||
}
|
||||
case "lastmod":
|
||||
p.Lastmod, err = cast.ToTimeE(v)
|
||||
if err != nil {
|
||||
jww.ERROR.Printf("Failed to parse lastmod '%v' in page %s", v, p.File.Path())
|
||||
}
|
||||
case "publishdate", "pubdate":
|
||||
p.PublishDate, err = cast.ToTimeE(v)
|
||||
if err != nil {
|
||||
@@ -524,6 +529,11 @@ func (p *Page) update(f interface{}) error {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if p.Lastmod.IsZero() {
|
||||
p.Lastmod = p.Date
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user