about summary refs log tree commit diff stats
path: root/templates/list.templ
diff options
context:
space:
mode:
authorAlan Pearce2024-06-24 21:48:36 +0200
committerAlan Pearce2024-06-24 23:09:15 +0200
commita2feb8c63c80a1f52830f562af2deb2c6065eaae (patch)
tree448ed15c5fb91099ef29528c529a35d6151d98ee /templates/list.templ
parent8623948592fa14958d340b006653fc57861c4fc4 (diff)
downloadwebsite-a2feb8c63c80a1f52830f562af2deb2c6065eaae.tar.lz
website-a2feb8c63c80a1f52830f562af2deb2c6065eaae.tar.zst
website-a2feb8c63c80a1f52830f562af2deb2c6065eaae.zip
move templ templates into separate package
Diffstat (limited to 'templates/list.templ')
-rw-r--r--templates/list.templ51
1 files changed, 51 insertions, 0 deletions
diff --git a/templates/list.templ b/templates/list.templ
new file mode 100644
index 0000000..602c15c
--- /dev/null
+++ b/templates/list.templ
@@ -0,0 +1,51 @@
+package templates
+
+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>
+}