apps/posts/layout.templ 2.1 K raw
1
package main
2
3
templ layout(site siteContext, title string, meta templ.Component, body templ.Component) {
4
	<!DOCTYPE html>
5
	<html lang="en">
6
		<head>
7
			<meta charset="UTF-8"/>
8
			<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
9
			<title>{ title }</title>
10
			if site.FaviconURL != "" {
11
				<link rel="apple-touch-icon" sizes="180x180" href={ site.FaviconURL }/>
12
				<link rel="icon" type="image/png" sizes="32x32" href={ site.FaviconURL }/>
13
				<link rel="icon" type="image/png" sizes="16x16" href={ site.FaviconURL }/>
14
			} else {
15
				<link rel="apple-touch-icon" sizes="180x180" href="/static/apple-touch-icon.png"/>
16
				<link rel="icon" type="image/png" sizes="32x32" href="/static/favicon-32x32.png"/>
17
				<link rel="icon" type="image/png" sizes="16x16" href="/static/favicon-16x16.png"/>
18
				<link rel="manifest" href="/static/site.webmanifest"/>
19
			}
20
			<meta name="theme-color" content="#121113"/>
21
			@meta
22
			<link rel="stylesheet" href="/assets/darkmatter.css"/>
23
			<link rel="stylesheet" href="/static/styles.css"/>
24
			<link rel="stylesheet" href="/custom-styles.css"/>
25
		</head>
26
		<body>
27
			if site.HeaderHTML != "" {
28
				<div class="custom-header">
29
					@templ.Raw(string(site.HeaderHTML))
30
				</div>
31
			}
32
			<header class="header">
33
				<a href="/" class="logo">{ site.BlogTitle }</a>
34
				<nav class="links">
35
					for _, l := range site.NavLinks {
36
						<a href={ templ.URL(l.URL) }>{ l.Label }</a>
37
					}
38
				</nav>
39
			</header>
40
			<main>
41
				@body
42
			</main>
43
			<footer class="footer">
44
				@templ.Raw(string(site.FooterHTML))
45
			</footer>
46
			<script>
47
				document.querySelectorAll('.post-date').forEach(el => {
48
					const d = new Date(el.textContent.trim());
49
					if (!isNaN(d)) {
50
						const day = String(d.getDate()).padStart(2, '0');
51
						const mon = d.toLocaleString('en-US', { month: 'short' });
52
						el.textContent = `${day} ${mon}, ${d.getFullYear()}`;
53
					}
54
				});
55
			</script>
56
		</body>
57
	</html>
58
}
59
60
templ ogImage(site siteContext) {
61
	if site.OGImageURL != "" {
62
		<meta property="og:image" content={ site.OGImageURL }/>
63
	} else {
64
		<meta property="og:image" content={ site.SiteURL + "/static/og.png" }/>
65
	}
66
}