# `gno.land/p/moul/pageable` Pagination for anything that can hand out a window of its items, plus the Markdown page picker to navigate it. Implement one method and you get pages, page sizes, reverse order, URL query parsing and a rendered picker: ```go type Pageable interface { Size() int IterateByOffset(offset, count int, cb func(index, value interface{}) bool) bool } ``` Note the single `IterateByOffset`. Some structures expose separate forward and reverse iteration; this interface deliberately does not. Direction is carried by the sign of `count` (offset 0 count 5 gives items 0..4; offset 0 count -5 gives 4..0), and the implementation handles it internally, so the pager has one code path instead of two. ## Use ```go pager := pageable.NewPager(source, 10 /* default page size */, false /* reversed */) page := pager.MustGetPageByPath(path) // reads ?page= and ?size= from the path out := "" for _, item := range page.Items { out += "- " + item.Value.(string) + "\n" // Item is {Index, Value interface{}} } out += page.Picker() // "1 | **2** | 3 | ..." as Markdown links ``` `GetPageByPath` returns an error instead of panicking; `MustGetPageByPath` is the Render-side shorthand. `PickerWithPath(path)` preserves the other query parameters (everything but `page`), which is what you want when the realm has its own filters in the URL. `GetPage(n)` and `GetPageWithSize(n, size)` skip URL parsing entirely. `Page` also carries `TotalItems`, `TotalPages`, `HasPrev` and `HasNext`, so a realm can render its own navigation instead of using `Picker()`. ## Nothing imports it The package doc claims two consumers, `p/nt/avl/pager` and `p/moul/ulist/pager`. Neither holds today: the upstream [`p/nt/avl/pager`](https://github.com/gnolang/gno/tree/master/examples/gno.land/p/nt/avl/pager) is a standalone AVL pager that does not import this interface, and `p/moul/ulist/pager` does not exist in this repository (`p/moul/ulist` ships `lplist`, not a pager). Grepping this repo, the only files mentioning `pageable` are its own source and test. So treat it as a proposed interface with a working reference implementation and a 410-line test, not as load-bearing code. The package doc comment has been corrected to say so. --- Part of **[moul/gno-contracts](https://github.com/moul/gno-contracts)** — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage. **Dependency graph:** ![gno.land/p/moul/pageable/v0 dependency graph](https://raw.githubusercontent.com/moul/gno-contracts/main/_assets/gno.land/p/moul/pageable/v0/deps.png) > ⚠️ **Disclaimer:** provided as-is, without warranty; not security-audited. Full disclaimer: [DISCLAIMER](https://github.com/moul/gno-contracts/blob/main/DISCLAIMER.md).