all repos — homestead @ 060e8b38e533b5e44eb9be3363790ece392c714d

Code for my website

hide tags and changelog in posts when not relevant

Alan Pearce
commit

060e8b38e533b5e44eb9be3363790ece392c714d

parent

20f1e1ca02d2e1f2079bd0205749ea5fb58c190a

1 file changed, 32 insertions(+), 28 deletions(-)

jump to
M templates/post.gotemplates/post.go
@@ -29,37 +29,41 @@ ),
Div(Class("e-content"), post, ), - Div(Class("tags"), - g.Text("Tags: "), - Ul(Class("p-categories tags"), - g.Map(post.Taxonomies.Tags, func(tag string) g.Node { - return Li( - tagLink(tag, Class("p-category")), - ) - }), + g.If(len(post.Taxonomies.Tags) > 0, + Div(Class("tags"), + g.Text("Tags: "), + Ul(Class("p-categories tags"), + g.Map(post.Taxonomies.Tags, func(tag string) g.Node { + return Li( + tagLink(tag, Class("p-category")), + ) + }), + ), ), ), - Details(Class("changelog"), - Summary(g.Text("Changelog")), - Ul( - g.Map(post.Commits, func(commit *vcs.Commit) g.Node { - return Li( - TitleAttr(commit.Description), - postDate(commit.Date, ""), - g.Text(" "), - A( - Href(commit.MakeFileLink(post.Input).String()), - g.Text(commit.Summary), - ), - g.Text(" "), - g.If( - len(commit.Description) > 0, - Small( - g.Text(" …"), + g.If(len(post.Commits) > 1, + Details(Class("changelog"), + Summary(g.Text("Changelog")), + Ul( + g.Map(post.Commits, func(commit *vcs.Commit) g.Node { + return Li( + TitleAttr(commit.Description), + postDate(commit.Date, ""), + g.Text(" "), + A( + Href(commit.MakeFileLink(post.Input).String()), + g.Text(commit.Summary), ), - ), - ) - }), + g.Text(" "), + g.If( + len(commit.Description) > 0, + Small( + g.Text(" …"), + ), + ), + ) + }), + ), ), ), ))