all repos — homestead @ 02344e6cb41515516464de403e2eae1caac81e5c

Code for my website

switch from templ to gomponent

Alan Pearce
commit

02344e6cb41515516464de403e2eae1caac81e5c

parent

4034ac2a849b499364d82b902896ca899d946c3a

1 file changed, 45 insertions(+), 0 deletions(-)

changed files
A templates/homepage.go
@@ -0,0 +1,45 @@
+package templates + +import ( + "go.alanpearce.eu/homestead/internal/config" + "go.alanpearce.eu/homestead/internal/content" + + g "maragu.dev/gomponents" + . "maragu.dev/gomponents/html" +) + +type HomepageVars struct { + Email string + Me []config.MenuItem + Posts []*content.Post +} + +func Homepage(site SiteSettings, vars HomepageVars, content g.Node) g.Node { + return Layout(site, PageSettings{ + Title: site.Title, + TitleAttrs: Class("p-name u-url"), + BodyAttrs: Class("h-card"), + }, + Div( + ID("content"), + content, + ), + Section( + H2(g.Text("Latest Posts")), + list(vars.Posts[0:5]), + ), + Section( + H2(g.Text("Elsewhere on the Internet")), + Ul(Class("elsewhere"), + Li( + A(Class("u-email"), Rel("me"), Href("mailto:"+vars.Email), g.Text(vars.Email)), + ), + g.Map(vars.Me, func(link config.MenuItem) g.Node { + return Li( + A(Class("u-url"), Rel("me"), Href(link.URL.String()), g.Text(link.Name)), + ) + }), + ), + ), + ) +}