all repos — homestead @ 3dde69cd0394b0f1fa33f7a7a773acabfa8acaa2

Code for my website

domain/content/publisher/templates/index.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
package templates

import (
	g "alin.ovh/gomponents"
	. "alin.ovh/gomponents/html"

	base "alin.ovh/homestead/domain/web/templates"
)

type PageSettings struct {
	User       string
	IsLoggedIn bool
	base.PageSettings
}

func IndexPage(site base.SiteSettings, page PageSettings) g.Node {
	return Layout(site, page.PageSettings,
		Div(
			H1(g.Textf("Welcome, %s!", page.User)),
			g.If(page.IsLoggedIn,
				Div(
					P(g.Text("You are currently logged in.")),
					P(
						A(
							g.Attr("href", "/admin/auth/logout"),
							g.Text("Logout"),
						),
					),
				),
			),
			g.If(!page.IsLoggedIn,
				Div(
					P(g.Text("Please log in to access protected features.")),
					P(
						A(
							g.Attr("href", "/admin/auth/login"),
							g.Text("Login"),
						),
					),
				),
			),
		),
	)
}