Skip to content

Commit

Permalink
fix rebased docs and add debug info
Browse files Browse the repository at this point in the history
  • Loading branch information
maxandersen committed Jul 31, 2017
1 parent 9fdcb7f commit 69329c4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/content/getting-started/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ disablePathToLower = false
enableEmoji = false
# Show a placeholder instead of the default value or an empty string if a translation is missing
enableMissingTranslationPlaceholders = false
# Regex to use for dates in filenames. Only used with `useFilenameDateAsFallback`
# Regex to use for dates in filenames.
filenameDateFallbackPattern = "(?P<year>\\d{4})\\-(?P<month>\\d{2})\\-(?P<day>\\d{2})"
# Time format for custom dates in filenames. Only used with `useFilenameDateAsFallback` and must match `filenameDateFallbackPattern`
filenameDateFallbackFormat = "2006-01-02"
Expand Down
7 changes: 6 additions & 1 deletion hugolib/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -1070,16 +1070,21 @@ func (p *Page) update(f interface{}) error {
p.Params["draft"] = p.Draft

if p.Date.IsZero() && p.s.Cfg.GetBool("useModTimeAsFallback") {

fi, err := p.s.Fs.Source.Stat(filepath.Join(p.s.PathSpec.AbsPathify(p.s.Cfg.GetString("contentDir")), p.File.Path()))
if err == nil {
p.s.Log.DEBUG.Printf("using file modification time as fallback for page %s", p.File.Path())
p.Date = fi.ModTime()
p.Params["date"] = p.Date
}
} else if p.Date.IsZero() && p.s.Cfg.GetString("filenameDateFallbackPattern") != "" {
}

if p.Date.IsZero() && p.s.Cfg.GetString("filenameDateFallbackPattern") != "" {
dateExp := regexp.MustCompile(p.s.Cfg.GetString("filenameDateFallbackPattern"))
dateString := dateExp.FindString(p.File.Path())
filenameDate, err := time.Parse(p.s.Cfg.GetString("filenameDateFallbackFormat"), dateString)
if err == nil {
p.s.Log.DEBUG.Printf("using filename date as fallback for page %s", p.File.Path())
p.Date = filenameDate
p.Params["date"] = p.Date
}
Expand Down

0 comments on commit 69329c4

Please sign in to comment.