summaryrefslogtreecommitdiff
path: root/src/http/tpl/posts.html
diff options
context:
space:
mode:
authorBrian Picciano <mediocregopher@gmail.com>2024-05-18 15:55:59 +0200
committerBrian Picciano <mediocregopher@gmail.com>2024-05-18 15:55:59 +0200
commit93a8843e2e3391459fd333aef9e5c7617608c2b3 (patch)
tree2e5615cd22d1b39c7d5f870b88e3f29b5c24a223 /src/http/tpl/posts.html
parent8d7e708d98a3a46ba3ba08f9c8deeb4838bb8ca5 (diff)
Remove most rendering related querying from go http handlers
Diffstat (limited to 'src/http/tpl/posts.html')
-rw-r--r--src/http/tpl/posts.html15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/http/tpl/posts.html b/src/http/tpl/posts.html
index 0701459..2fa336d 100644
--- a/src/http/tpl/posts.html
+++ b/src/http/tpl/posts.html
@@ -1,8 +1,11 @@
{{ define "body" }}
- {{ if ge .Payload.PrevPage 0 }}
+ {{ $page := .GetQueryIntValue "p" 0 -}}
+ {{ $getPostsRes := .GetPosts $page 20 -}}
+
+ {{ if gt $page 0 }}
<p>
- <a href="?p={{ .Payload.PrevPage}}">&lt; &lt; Previous Page</a>
+ <a href="?p={{ .Add $page -1 }}">&lt; &lt; Previous Page</a>
</p>
{{ else }}
<p>
@@ -12,10 +15,10 @@
{{ end }}
<ul>
- {{ range .Payload.Posts }}
+ {{ range $getPostsRes.Posts }}
<li>
<strong><a href="{{ PostURL .ID }}">
- {{ DateTimeFormat .PublishedAt }} / {{ .Title }}
+ {{ .PublishedAt.Format "2006-01-02" }} - {{ .Title }}
</a></strong>
{{ if .Description }}
<br/><em>{{ .Description }}</em>
@@ -24,9 +27,9 @@
{{ end }}
</ul>
- {{ if ge .Payload.NextPage 0 }}
+ {{ if $getPostsRes.HasMore }}
<p>
- <a href="?p={{ .Payload.NextPage}}">Next Page &gt; &gt;</a>
+ <a href="?p={{ .Add $page 1 }}">Next Page &gt; &gt;</a>
</p>
{{ end }}