all repos — homestead @ 02344e6cb41515516464de403e2eae1caac81e5c

Code for my website

switch from templ to gomponent

Alan Pearce
commit

02344e6cb41515516464de403e2eae1caac81e5c

parent

4034ac2a849b499364d82b902896ca899d946c3a

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, + ), + )) +}