Add pager size argument to paginator methods

Fixes #1013
This commit is contained in:
bep 2015-03-31 19:12:54 +02:00
parent b8877ebb5b
commit ef3a925647

View File

@ -17,7 +17,7 @@ Hugo supports pagination for the home page, sections and taxonomies. It's built
Pagination can be configured in the site configuration (e.g. `config.toml`): Pagination can be configured in the site configuration (e.g. `config.toml`):
* `Paginate` (default `10`) * `Paginate` (default `10`) (this setting can be overridden in the template)
* `PaginatePath` (default `page`) * `PaginatePath` (default `page`)
Setting `Paginate` to a positive value will split the list pages for the home page, sections and taxonomies into chunks of that size. But note that the generation of the pagination pages for sections, taxonomies and home page is *lazy* --- the pages will not be created if not referenced by a `.Paginator` (see below). Setting `Paginate` to a positive value will split the list pages for the home page, sections and taxonomies into chunks of that size. But note that the generation of the pagination pages for sections, taxonomies and home page is *lazy* --- the pages will not be created if not referenced by a `.Paginator` (see below).
@ -35,6 +35,12 @@ There are two ways to configure and use a `.Paginator`:
For a given **Node**, it's one of the options above. The `.Paginator` is static and cannot change once created. For a given **Node**, it's one of the options above. The `.Paginator` is static and cannot change once created.
The global page size setting (`Paginate`) can be overridden by providing a positive integer as the last argument. The examples below will give five items per page:
* `{{ range (.Paginator 5).Pages }}`
* `{{ $paginator := .Paginate (where .Data.Pages "Type" "post") 5 }}`
## Build the navigation ## Build the navigation
The `.Paginator` contains enough information to build a paginator interface. The `.Paginator` contains enough information to build a paginator interface.