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
|
package main
import "fmt"
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="alternate" type="application/atom+xml" href="/feed.atom"/>
<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!") {
<header>
<h1>jolheiser</h1>
<p>Just a guy living in the middle of nowhere who likes to hack on open-source.</p>
</header>
<main>
for category, articles := range articles {
if Published(articles) > 0 {
<h3>{ category }</h3>
<ul>
for _, article := range articles {
if !article.Draft {
<li><a href={ templ.SafeURL(article.Slug()) }>{ article.Title }</a></li>
}
}
</ul>
}
}
</main>
}
}
templ ArticleTemplate(article Article) {
@baseTemplate(article.Title, article.Summary) {
<header>
<h1><a href="/"><small>jolheiser</small></a></h1>
<hr/>
<h2>{ article.Title }</h2>
<div style="display:flex;">
<p style="flex:auto;"><em>{ article.Category }</em></p>
<p style="flex:auto;"><em title={ article.Date.Format("Monday, January 2, 2006") }>{ article.Date.Format("Mon, 02 Jan 2006") }</em></p>
</div>
</header>
<main>
@templ.Raw(article.Content)
</main>
<footer><a href={ templ.SafeURL(fmt.Sprintf("https://git.jolheiser.com/blog/tree/%s/%s", ref, article.path)) }>source</a></footer>
}
}
|