Home

blog @53ddd6258454db5bdf843d26e62da6a51b757ef2 - 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
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"/>
		</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>
			<h3>{ article.Date.Format("01/02/2006") }</h3>
		</header>
		<main>@templ.Raw(article.Content)</main>
	}
}