feat: add footer which includes the repo link

This commit is contained in:
rramiachraf 2022-12-17 21:45:45 +01:00
parent 9371e53972
commit f01607946a
6 changed files with 57 additions and 16 deletions

View File

@ -161,9 +161,9 @@ a {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 1.5rem; gap: 1.5rem;
justify-content: center;
align-items: center; align-items: center;
padding: 2rem; padding: 2rem;
flex-grow: 1;
} }
#home div { #home div {
@ -198,3 +198,27 @@ a {
align-items: center; align-items: center;
} }
} }
footer {
text-align: center;
background-color: #ffcd38;
padding: 1rem;
}
footer a {
font-weight: 500;
color: #1b1a17;
transition: .3s ease text-decoration;
font-size: 1.4rem;
text-transform: uppercase;
}
footer a:hover {
text-decoration: underline;
}
#app {
display: flex;
flex-direction: column;
min-height: 100vh;
}

View File

@ -60,9 +60,17 @@ func securityHeaders(next http.Handler) http.Handler {
}) })
} }
func getTemplates(templates ...string) []string {
var pths []string
for _, t := range templates {
tmpl := path.Join("views",fmt.Sprintf("%s.tmpl", t))
pths = append(pths, tmpl)
}
return pths
}
func render(n string, w http.ResponseWriter, data any) { func render(n string, w http.ResponseWriter, data any) {
tmpl := fmt.Sprintf("%s.tmpl",n ) t, err := template.ParseFiles(getTemplates(n, "navbar", "footer")...)
t, err := template.ParseFiles(path.Join("views", tmpl))
if err != nil { if err != nil {
w.WriteHeader(http.StatusInternalServerError) w.WriteHeader(http.StatusInternalServerError)
return return

5
views/footer.tmpl Normal file
View File

@ -0,0 +1,5 @@
{{define "footer"}}
<footer>
<a target="_blank" href="https://github.com/rramiachraf/dumb">Source Code</a>
</footer>
{{end}}

View File

@ -7,10 +7,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
</head> </head>
<body> <body>
<nav> <main id="app">
<a href="/"><img src="/static/logo.svg" /></a> {{template "navbar"}}
</nav>
<div id="home"> <div id="home">
<div> <div>
<h1>Welcome to dumb</h1> <h1>Welcome to dumb</h1>
@ -18,5 +16,7 @@
</div> </div>
<code>Just redirect Genius URLs to this instance and It's all good.</code> <code>Just redirect Genius URLs to this instance and It's all good.</code>
</div> </div>
{{template "footer"}}
</div>
</body> </body>
</html> </html>

View File

@ -8,9 +8,7 @@
<script type="text/javascript" src="/static/script.js" defer></script> <script type="text/javascript" src="/static/script.js" defer></script>
</head> </head>
<body> <body>
<nav> {{template "navbar"}}
<a href="/"><img src="/static/logo.svg" /></a>
</nav>
<div id="container"> <div id="container">
<div id="metadata"> <div id="metadata">
<img src="{{.Image}}"/> <img src="{{.Image}}"/>
@ -35,5 +33,6 @@
</div> </div>
</div> </div>
</div> </div>
{{template "footer"}}
</body> </body>
</html> </html>

5
views/navbar.tmpl Normal file
View File

@ -0,0 +1,5 @@
{{define "navbar"}}
<nav>
<a href="/"><img src="/static/logo.svg" /></a>
</nav>
{{end}}