all repos — homestead @ 511f6c8cbdd7e2569f1658ede931fbb8b505c952

Code for my website

templates/tags.go (view raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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))
}