Merge pull request #8 from rramiachraf/7-add-link-to-this-repository-on-website

feat: add footer which includes the repo link
This commit is contained in:
Achraf RRAMI 2022-12-17 20:47:21 +00:00 committed by GitHub
commit 5fa6754f23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 57 additions and 16 deletions

View File

@ -161,9 +161,9 @@ a {
display: flex;
flex-direction: column;
gap: 1.5rem;
justify-content: center;
align-items: center;
padding: 2rem;
flex-grow: 1;
}
#home div {
@ -198,3 +198,27 @@ a {
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) {
tmpl := fmt.Sprintf("%s.tmpl",n )
t, err := template.ParseFiles(path.Join("views", tmpl))
t, err := template.ParseFiles(getTemplates(n, "navbar", "footer")...)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
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" />
</head>
<body>
<nav>
<a href="/"><img src="/static/logo.svg" /></a>
</nav>
<main id="app">
{{template "navbar"}}
<div id="home">
<div>
<h1>Welcome to dumb</h1>
@ -18,5 +16,7 @@
</div>
<code>Just redirect Genius URLs to this instance and It's all good.</code>
</div>
{{template "footer"}}
</div>
</body>
</html>

View File

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