show date last updated for posts with multiple commits
1 file changed, 9 insertions(+), 1 deletion(-)
changed files
M internal/content/posts.go → internal/content/posts.go
@@ -13,6 +13,7 @@ "strings" "time" "go.alanpearce.eu/website/internal/markdown" + "go.alanpearce.eu/website/internal/vcs" "go.alanpearce.eu/x/log" "github.com/adrg/frontmatter"@@ -34,6 +35,7 @@ Input string Output string Basename string URL string + Commits []*vcs.Commit *PostMatter content []byte@@ -42,6 +44,7 @@ type Config struct { Root string PostDir string + Repo *vcs.Repository } type Collection struct {@@ -66,15 +69,20 @@ func (cc *Collection) GetPost(filename string) (*Post, error) { fp := filepath.Join(cc.config.Root, filename) url := path.Join("/", postURLReplacer.Replace(filename)) + "/" + cs, err := cc.config.Repo.GetFileLog(filename) + if err != nil { + return nil, errors.WithMessagef(err, "could not get commit log for file %s", filename) + } post := &Post{ Input: fp, Output: postOutputReplacer.Replace(filename), Basename: filepath.Base(url), URL: url, PostMatter: &PostMatter{}, + Commits: cs, } - err := parse(fp, post) + err = parse(fp, post) if err != nil { return nil, err }