all repos — homestead @ 02344e6cb41515516464de403e2eae1caac81e5c

Code for my website

templates/page.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
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,
		),
	))
}