Home

blog @35d9f8dde6cae1107825fbc662591e1f784eff98 - refs - log -
-
https://git.jolheiser.com/blog.git
My nonexistent blog
blog / templates.templ
- raw
 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
package main

templ baseTemplate(title, description string) {
	<!DOCTYPE html>
	<html>
		<head>
			<meta charset="UTF-8"/>
			<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
			<title>{ title }</title>
			<meta property="og:title" content={ title }/>
			<meta property="og:description" content={ description }/>
			<link rel="stylesheet" href="/sakura.css"/>
			<link rel="stylesheet" href="/chroma.css"/>
			<link rel="stylesheet" href="/jolheiser.css"/>
		</head>
		<body>
			{ children... }
		</body>
	</html>
}

templ IndexTemplate(articles Articles) {
	@baseTemplate("jolheiser's blog", "Hahaha yes.....YES!") {
		<main>
			for category, articles := range articles {
				<h2>{ category }</h2>
				<ul>
					for _, article := range articles {
						<li><a href={ templ.SafeURL(article.Slug()) }>{ article.Title }</a></li>
					}
				</ul>
			}
		</main>
	}
}

templ ArticleTemplate(article Article) {
	@baseTemplate(article.Title, article.Summary) {
		<header>
			<h1>{ article.Title }</h1>
			<div style="display:flex;">
				<p style="flex:auto;"><em>{ article.Category }</em></p>
				<p style="flex:auto;"><em>{ article.Date.Format("Mon, 02 Jan 2006") }</em></p>
			</div>
		</header>
		<main>@templ.Raw(article.Content)</main>
	}
}