This repository was archived by the owner on Oct 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpage_layout.templ
More file actions
103 lines (98 loc) · 3.61 KB
/
Copy pathpage_layout.templ
File metadata and controls
103 lines (98 loc) · 3.61 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package main
import (
"time"
"strconv"
)
templ layout(title, description string, contents templ.Component) {
<!DOCTYPE html>
<html lang="en">
@head(title, description)
@body(contents)
@footer()
</html>
}
templ head(title, description string) {
<head>
<title>{ title }</title>
<link rel="stylesheet" href="/static/style.css"/>
<link rel="icon" href="/static/favicon.ico" type="image/x-icon"/>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta name="author" content="Karl Skewes"/>
<meta name="copyright" content="© 2025 Karl Skewes"/>
<meta name="description" content="{ description }"/>
<meta http-equiv="X-UA-Compatible" content="ie=edge"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script src="/static/htmx_2.0.4.js"></script>
<link rel="stylesheet" href="/static/style.css"/>
</head>
}
templ body(contents templ.Component) {
<header class="bg-amber-400 sm:flex sm:justify-between sm:px-4 sm:py-4 sm:items-center">
<div class="flex items-center justify-between px-4 py-3 sm:p-0">
<div>
<a href="/" title="Home">
<img class="h-20" src="/static/gopher-trophy.svg" alt="gopher holding trophy"/>
</a>
</div>
<div class="bg-gray-700 rounded">
<!-- TODO - why is this not justify-between'd - justified within parent
div, doesn't include menu links outside this div...-->
<h1 class="text-white text-4xl px-4 py-4">Go Subs</h1>
</div>
<div class="sm:hidden">
<script>/* Toggle between showing and hiding the navigation menu links when the user clicks on the hamburger menu / bar icon */
function toggleHamburger() {
var closed = document.getElementById("hb-closed");
var open = document.getElementById("hb-open");
var navlinks = document.getElementById("navlinks");
if (closed.style.display === "block") {
closed.style.display = "none";
open.style.display = "block";
navlinks.style.display = "none";
} else {
closed.style.display = "block";
open.style.display = "none";
navlinks.style.display = "block";
}
}
</script>
<div class="cursor-pointer block text-gray-500 focus:outline-none">
<svg class="h-8 w-8 fill-current" viewBox="0 0 24 24" onclick="toggleHamburger()">
<path
style="display:none"
id="hb-closed"
v-if="isOpen"
fill-rule="evenodd"
d="M5.47 5.47a.75.75 0 0 1 1.06 0L12 10.94l5.47-5.47a.75.75 0 1 1 1.06 1.06L13.06 12l5.47 5.47a.75.75 0 1 1-1.06 1.06L12 13.06l-5.47 5.47a.75.75 0 0 1-1.06-1.06L10.94 12 5.47 6.53a.75.75 0 0 1 0-1.06Z"
></path>
<path
id="hb-open"
v-if="!isOpen"
fill-rule="evenodd"
d="M3 6.75A.75.75 0 0 1 3.75 6h16.5a.75.75 0 0 1 0 1.5H3.75A.75.75 0 0 1 3 6.75ZM3 12a.75.75 0 0 1 .75-.75h16.5a.75.75 0 0 1 0 1.5H3.75A.75.75 0 0 1 3 12Zm0 5.25a.75.75 0 0 1 .75-.75h16.5a.75.75 0 0 1 0 1.5H3.75a.75.75 0 0 1-.75-.75Z"
></path>
</svg>
</div>
</div>
</div>
<!-- TODO vue equivalent of isOpen !isOpen if open, class="block" else class="hidden" -->
<div id="navlinks" class="hidden px-2 pt-2 pb-4 sm:flex sm:p-0">
<a class="block px-2 py-1 text-white font-semibold hover:bg-gray-800 rounded" href="/">Home</a>
</div>
</header>
<div class="bg-white my-2 w-full flex flex-col space-y-4 md:flex-row md:space-x-4 md:space-y-0">
<main class="bg-sky-300 w-full px-2 py-5">
<article>
<div id="content">
@contents
</div>
</article>
</main>
</div>
}
templ footer() {
<footer class="bg-slate-800 mt-auto p-5 text-gray-200">
<p>© { strconv.Itoa(time.Now().Year()) } Karl Skewes</p>
</footer>
}