Paginating a list of posts

The Paginator class creates a generator that yields a list of posts for each page, where the length of each page is passed in when configuring the paginator.

This class is useful for building paginated lists of posts, such as a list of posts for a given month or year or for a category of content.

class indieweb_utils.Paginator(series: list, per_page: int)[source]
get_page(page: int) List[Dict[str, Any]][source]

Get a specific page of objects.

Parameters:

page – The page to get.

Returns:

A list of objects.

next_page() List[Dict[str, Any]][source]

Get the next page of objects.

Parameters:

current_page – The current page.

Returns:

A list of objects.

paginate_list(series: list, per_page: int) Dict[str, List[Dict[str, Any]]][source]

Create a paginator for a series of objects.

Parameters:

series – A list of objects to paginate.

Returns:

A dictionary containing the paginated objects.

previous_page() List[Dict[str, Any]][source]

Get the previous page of objects.

Parameters:

current_page – The current page.

Returns:

A list of objects.