switch from templ to gomponent
1 file changed, 36 insertions(+), 0 deletions(-)
changed files
A templates/page.go
@@ -0,0 +1,36 @@ +package templates + +import ( + "go.alanpearce.eu/homestead/internal/content" + + g "maragu.dev/gomponents" + . "maragu.dev/gomponents/html" +) + +func Page(site SiteSettings, page *content.Post) g.Node { + return Layout(site, PageSettings{ + Title: page.Title, + TitleAttrs: g.Group([]g.Node{Class("h-card"), Rel("author")}), + }, Article( + Header( + H1(Class("p-name"), g.Text(page.Title)), + P( + Class("meta"), + g.If(!page.Date.IsZero(), + Span(Class("date"), + g.Text("Published: "), + A(Class("u-url"), Href(page.URL), postDate(page.Date, "dt-published")), + ), + ), + // one commit: not updated + g.Iff( + (page.Date.IsZero() && len(page.Commits) > 0) || len(page.Commits) > 1, + lastUpdated(page), + ), + ), + ), + Div(Class("content"), + page, + ), + )) +}