From d7a5d425b8361e2b5b2b381f773b5393fa43d7b8 Mon Sep 17 00:00:00 2001 From: Leon Mika Date: Sun, 22 Mar 2026 14:34:55 +1100 Subject: [PATCH] feat: add pagination controls to admin post list Co-Authored-By: Claude Opus 4.6 --- models/paging.go | 9 +++++++++ views/posts/index.html | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/models/paging.go b/models/paging.go index 4ba0c9f..b4e514b 100644 --- a/models/paging.go +++ b/models/paging.go @@ -26,3 +26,12 @@ func (p PageInfo) PreviousPage() int { func (p PageInfo) NextPage() int { return p.CurrentPage + 1 } + +// Pages returns a slice of page numbers for rendering numbered pagination. +func (p PageInfo) Pages() []int { + pages := make([]int, p.TotalPages) + for i := range pages { + pages[i] = i + 1 + } + return pages +} diff --git a/views/posts/index.html b/views/posts/index.html index bbf445d..7786539 100644 --- a/views/posts/index.html +++ b/views/posts/index.html @@ -62,4 +62,22 @@ {{ end }} {{ end }} + + {{ if gt .pageInfo.TotalPages 1 }} + + {{ end }} \ No newline at end of file