diff options
author | Brian Picciano <mediocregopher@gmail.com> | 2022-05-14 21:30:18 -0600 |
---|---|---|
committer | Brian Picciano <mediocregopher@gmail.com> | 2022-05-14 21:35:53 -0600 |
commit | 788aba3d0d0bc98c0164f87cf3a4941cf4587a54 (patch) | |
tree | 789ea80de8041352a5e2ecda01334b1bbfc3ddbc /srv/src/api | |
parent | af08122a253916c9f7d923b6a0197db1cbbf536e (diff) |
Fix new index page
Diffstat (limited to 'srv/src/api')
-rw-r--r-- | srv/src/api/render.go | 2 | ||||
-rw-r--r-- | srv/src/api/tpl/index.html | 48 |
2 files changed, 29 insertions, 21 deletions
diff --git a/srv/src/api/render.go b/srv/src/api/render.go index 6359505..cacdb26 100644 --- a/srv/src/api/render.go +++ b/srv/src/api/render.go @@ -42,7 +42,7 @@ func mustParseTpl(name string) *template.Template { func (a *api) renderIndexHandler() http.Handler { tpl := mustParseTpl("index.html") - const pageCount = 20 + const pageCount = 10 return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { diff --git a/srv/src/api/tpl/index.html b/srv/src/api/tpl/index.html index b71dc01..1858ea8 100644 --- a/srv/src/api/tpl/index.html +++ b/srv/src/api/tpl/index.html @@ -1,28 +1,36 @@ {{ define "body" }} -<ul id="posts-list"> - - {{ range .Posts }} - <li> - <h2> - <a href="{{ .HTTPPath }}">{{ .Title }}</a> - </h2> - <span>{{ .PublishedAt.Format "2006-01-02" }}</span> - {{ if not .LastUpdatedAt.IsZero }} - <span>(Updated {{ .LastUpdatedAt.Format "2006-01-02" }})</span> + + <ul id="posts-list"> + + {{ range .Posts }} + <li> + <h2> + <a href="posts/{{ .HTTPPath }}">{{ .Title }}</a> + </h2> + <span>{{ .PublishedAt.Format "2006-01-02" }}</span> + {{ if not .LastUpdatedAt.IsZero }} + <span>(Updated {{ .LastUpdatedAt.Format "2006-01-02" }})</span> + {{ end }} + <p>{{ .Description }}</p> + </li> {{ end }} - <p>{{ .Description }}</p> - </li> - {{ end }} -</ul> -{{ end }} + </ul> -{{ if ge .PrevPage 0 }} -<a href="?p={{ .PrevPage}}">Previous</a> -{{ end }} + {{ if or (ge .PrevPage 0) (ge .NextPage 0) }} + <div id="page-turner"> + + {{ if ge .PrevPage 0 }} + <a style="float: left;" href="?p={{ .PrevPage}}">Newer</a> + {{ end }} + + {{ if ge .NextPage 0 }} + <a style="float:right;" href="?p={{ .NextPage}}">Older</a> + {{ end }} + + </div> + {{ end }} -{{ if ge .NextPage 0 }} -<a href="?p={{ .NextPage}}">Next</a> {{ end }} {{ template "base.html" . }} |