blob: be3bd50d1e837ca58e7fd09f99194f74dd4ee556 (
plain)
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
|
package main
import (
"net/http"
. "github.com/maragudk/gomponents"
. "github.com/maragudk/gomponents/components"
. "github.com/maragudk/gomponents/el"
)
func main() {
_ = http.ListenAndServe("localhost:8080", http.HandlerFunc(handler))
}
func handler(w http.ResponseWriter, r *http.Request) {
p := page(props{
title: r.URL.Path,
path: r.URL.Path,
})
_ = p.Render(w)
}
type props struct {
title string
path string
}
func page(p props) Node {
return HTML5(DocumentProps{
Title: p.title,
Language: "en",
Body: []Node{
H1(p.title),
P(Textf("Welcome to the page at %v.", p.path)),
},
})
}
|