package html import "go.jolheiser.com/ugit/internal/git" import "github.com/dustin/go-humanize" import "go.jolheiser.com/ugit/assets" type IndexContext struct { BaseContext Profile IndexProfile Repos []*git.Repo } type IndexProfile struct { Username string Email string Links []IndexLink } type IndexLink struct { Name string URL string } func lastCommit(repo *git.Repo, human bool) string { c, err := repo.LastCommit() if err != nil { return "" } if human { return humanize.Time(c.When) } return c.When.Format("01/02/2006 03:04:05 PM") } templ Index(ic IndexContext) { @base(ic.BaseContext) {

{ ic.Title }

{ ic.Description }

if ic.Profile.Username != "" {
{ `@` + ic.Profile.Username }
} if ic.Profile.Email != "" {
@templ.Raw(string(assets.EmailIcon))
{ ic.Profile.Email }
}
for _, link := range ic.Profile.Links {
@templ.Raw(string(assets.LinkIcon))
{ link.Name }
}
for _, repo := range ic.Repos {
{ repo.Meta.Description }
for _, tag := range repo.Meta.Tags { { tag } }
{ lastCommit(repo, true) }
}
} }