package templates import ( "fmt" "github.com/go-git/go-git/v5/plumbing" "go.alanpearce.eu/elgit/git" g "go.alanpearce.eu/gomponents" . "go.alanpearce.eu/gomponents/html" ) // LogPage renders the commit log page func LogPage(data PageData, commits []*git.CommitReference) g.Node { return Page(data, []g.Node{ RepoHeader(data), RenderNav(data), Main( Log(data, commits), ), }) } func Log(data PageData, commits []*git.CommitReference) g.Node { return Div(Class("log"), g.Map(commits, func(commit *git.CommitReference) g.Node { return g.Group{ Div(Class("commit-header"), Div( A( Href(fmt.Sprintf("/%s/commit/%s", data.Name, commit.Hash.String())), Class("commit-hash"), g.Text(commit.Hash.String()[:8]), ), g.Text(" "), g.If( commit.HasReference(), g.Map(commit.References(), func(ref *plumbing.Reference) g.Node { return A( Href(fmt.Sprintf("/%s/tree/%s", data.Name, ref.Name().Short())), Class("commit-hash"), g.Text(ref.Name().Short()), ) }), ), ), Pre(g.Text(commit.Message)), ), CommitInfo(commit.Author), } }), ) }