all repos — homestead @ 02344e6cb41515516464de403e2eae1caac81e5c

Code for my website

switch from templ to gomponent

Alan Pearce
commit

02344e6cb41515516464de403e2eae1caac81e5c

parent

4034ac2a849b499364d82b902896ca899d946c3a

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

changed files
A templates/tags.go
@@ -0,0 +1,30 @@
+package templates + +import ( + g "maragu.dev/gomponents" + . "maragu.dev/gomponents/html" +) + +type TagsPageVars struct { + Title string + Tags []string +} + +func TagsPage(site SiteSettings, vars TagsPageVars) g.Node { + return Layout(site, PageSettings{ + Title: vars.Title, + }, Div( + H3(Class("filter"), g.Text("Tags")), + Ul(Class("tags"), + g.Map(vars.Tags, func(tag string) g.Node { + return Li(Class("h-feed"), + tagLink(tag, Class("")), + ) + }), + ), + )) +} + +func tagLink(tag string, attrs g.Node) g.Node { + return A(attrs, Href("/tags/"+tag), g.Text("#"+tag)) +}