domain/content/templates/homepage.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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | package templates
import (
g "alin.ovh/gomponents"
. "alin.ovh/gomponents/html"
"alin.ovh/homestead/domain/content"
"alin.ovh/homestead/domain/web/templates"
"alin.ovh/homestead/shared/config"
)
type HomepageVars struct {
Email string
Me []config.MenuItem
Posts []*content.Post
}
func Homepage(site templates.SiteSettings, vars HomepageVars, content g.Node) g.Node {
return templates.Layout(site, templates.PageSettings{
Title: site.Title,
TitleAttrs: templates.Attrs{"class": "p-name u-url"},
BodyAttrs: templates.Attrs{"class": "h-card"},
},
Div(
ID("content"),
content,
),
Section(
H2(g.Text("Latest Posts")),
list(vars.Posts[0:min(len(vars.Posts), 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)),
)
}),
),
),
)
}
|