Functions
register
Register pagination helper functions with Jinja2 environment.
register
def register(env: Environment, site: Site) -> None
Register pagination helper functions with Jinja2 environment.
Parameters 2
| Name | Type | Default | Description |
|---|---|---|---|
env |
Environment |
— | |
site |
Site |
— |
paginate_items
Paginate a list of items.
paginate_items
def paginate_items(items: list[Any], per_page: int = 10, current_page: int = 1) -> dict[str, Any]
Paginate a list of items.
Parameters 3
| Name | Type | Default | Description |
|---|---|---|---|
items |
list[Any] |
— | List to paginate |
per_page |
int |
10 |
Items per page (default: 10) |
current_page |
int |
1 |
Current page number (1-indexed) |
Returns
Dictionary with pagination datadict[str, Any]
—
page_url
Generate URL for a pagination page.
page_url
def page_url(base_path: str, page_num: int) -> str
Generate URL for a pagination page.
Parameters 2
| Name | Type | Default | Description |
|---|---|---|---|
base_path |
str |
— | Base path (e.g., "/posts/") |
page_num |
int |
— | Page number |
Returns
URL for that pagestr
—
page_range
Generate page range with ellipsis for pagination controls.
page_range
def page_range(current_page: int, total_pages: int, window: int = 2) -> list[int | None]
Generate page range with ellipsis for pagination controls.
Parameters 3
| Name | Type | Default | Description |
|---|---|---|---|
current_page |
int |
— | Current page number |
total_pages |
int |
— | Total number of pages |
window |
int |
2 |
Number of pages to show around current (default: 2) |
Returns
List of page numbers with None for ellipsislist[int | None]
—