Add GitInfo

This commit adds a `GitInfo` object to `Page` if `EnableGitInfo` is set.

It then also sets `Lastmod` for the given `Page` to the author date provided by Git.

The Git integrations should be fairly performant, but it adds "some time" to the build, somewhat depending on the Git history size.

If you want, you can run without during development and turn it on when deploying to the live server: `hugo --enableGitInfo`.

Fixes #2102
This commit is contained in:
Bjørn Erik Pedersen
2016-11-01 23:04:12 +01:00
committed by GitHub
parent 186db7cd7a
commit e8380e612f
8 changed files with 89 additions and 1 deletions

View File

@@ -216,6 +216,9 @@ func (h *HugoSites) Build(config BuildCfg) error {
}
}
// TODO(bep) make a more logical grouping of these.
h.assembleGitInfo()
for _, s := range h.Sites {
if err := s.postProcess(); err != nil {
return err
@@ -288,6 +291,7 @@ func (h *HugoSites) Rebuild(config BuildCfg, events ...fsnotify.Event) error {
h.setupTranslations(firstSite)
if changed.source {
h.assembleGitInfo()
for _, s := range h.Sites {
if err := s.postProcess(); err != nil {
return err