mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
add base/footer/header templates and use them on home route
This commit is contained in:
parent
743cc82a87
commit
65e760454c
|
@ -167,7 +167,13 @@ type homeRouteData struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (app *application) homeRoute(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
func (app *application) homeRoute(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
||||||
t, err := template.ParseFiles("./web/templates/home.page.gohtml")
|
t, err := template.ParseFiles(
|
||||||
|
"./web/templates/base.template.gohtml",
|
||||||
|
"./web/templates/header.partial.gohtml",
|
||||||
|
"./web/templates/footer.partial.gohtml",
|
||||||
|
"./web/templates/home.page.gohtml",
|
||||||
|
)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.Log.Error(err)
|
app.Log.Error(err)
|
||||||
return
|
return
|
||||||
|
|
18
web/templates/base.template.gohtml
Normal file
18
web/templates/base.template.gohtml
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta content="width=device-width,initial-scale=1" name="viewport">
|
||||||
|
<title>{{ template "title" . }}</title>
|
||||||
|
<meta property="og:title" content="nourybot - lidl twitch bot">
|
||||||
|
<meta property="og:description" content="nourybot">
|
||||||
|
</head>
|
||||||
|
<header>
|
||||||
|
{{ template "header" .}}
|
||||||
|
</header>
|
||||||
|
<body>
|
||||||
|
{{ template "body" . }}
|
||||||
|
</body>
|
||||||
|
<footer>
|
||||||
|
{{ template "footer" . }}
|
||||||
|
</footer>
|
3
web/templates/footer.partial.gohtml
Normal file
3
web/templates/footer.partial.gohtml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{{define "footer"}}
|
||||||
|
Powered by <a href="https://go.dev/">Go</a>
|
||||||
|
{{end}}
|
3
web/templates/header.partial.gohtml
Normal file
3
web/templates/header.partial.gohtml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{{define "header"}}
|
||||||
|
<h1><a href='/'>nourybot</a></h1>
|
||||||
|
{{end}}
|
|
@ -1,13 +1,5 @@
|
||||||
<!DOCTYPE html>
|
{{define "title"}}nourybot{{end}}
|
||||||
<html lang="en">
|
{{define "body"}}
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta content="width=device-width,initial-scale=1" name="viewport">
|
|
||||||
<title>nourybot - lidl twitch bot</title>
|
|
||||||
<meta property="og:title" content="nourybot - lidl twitch bot">
|
|
||||||
<meta property="og:description" content="nourybot">
|
|
||||||
</head>
|
|
||||||
<h1>nourybot</h1>
|
|
||||||
<p>Channels connected to:</hp>
|
<p>Channels connected to:</hp>
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -21,5 +13,6 @@
|
||||||
<td>{{ .Login }}</td>
|
<td>{{ .Login }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
</table>
|
</table>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
Loading…
Reference in a new issue