about summary refs log tree commit diff stats
path: root/internal/builder/list.templ
blob: 24cafe85c5203f5f4046c7a1162f84b4fee78b72 (plain)
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
package builder

import (
	"website/internal/config"
	"website/internal/content"
)

templ tagPage(config config.Config, tag string, posts []content.Post, path string) {
	@page(config, PageSettings{
		Title: tag,
		Path:  path,
		TitleAttrs: templ.Attributes{
			"class": "p-author h-card",
			"rel":   "author",
		},
	}) {
		<div class="filter">
			<h3 class="filter">#{ tag }</h3>
			<small>
				<a href="../">Remove filter</a>
			</small>
		</div>
		@list(posts)
	}
}

templ listPage(config config.Config, posts []content.Post, path string) {
	@page(config, PageSettings{
		Title: config.Title,
		TitleAttrs: templ.Attributes{
			"class": "p-author h-card",
			"rel":   "author",
		},
		Path: path,
	}) {
		@list(posts)
	}
}

templ list(posts []content.Post) {
	<ul class="h-feed">
		for _, post := range posts {
			<li class="h-entry">
				<span>
					@postDate(post.Date)
				</span>
				<a class="p-name u-url" href={ templ.SafeURL(post.URL) }>{ post.Title }</a>
			</li>
		}
	</ul>
}