Paging #4

Merged
lmika merged 13 commits from feature/pages-and-paging into main 2026-03-22 05:23:54 +00:00
Showing only changes of commit 113789a972 - Show all commits

28
models/paging.go Normal file
View file

@ -0,0 +1,28 @@
package models
// PageInfo carries pagination state for templates.
type PageInfo struct {
CurrentPage int
TotalPages int
PostsPerPage int
}
// HasPrevious returns true if there is a previous page.
func (p PageInfo) HasPrevious() bool {
return p.CurrentPage > 1
}
// HasNext returns true if there is a next page.
func (p PageInfo) HasNext() bool {
return p.CurrentPage < p.TotalPages
}
// PreviousPage returns the previous page number.
func (p PageInfo) PreviousPage() int {
return p.CurrentPage - 1
}
// NextPage returns the next page number.
func (p PageInfo) NextPage() int {
return p.CurrentPage + 1
}