Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Pagination Documentation #973

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions bridgetown-website/src/_data/bridgetown_variables/paginator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,26 @@
description: Total number of resources
- name: total_pages
description: Total number of paginated pages
- name: previous_page
- name: first_page_path
description: >-
The number of the previous page, or <code>nil</code> if no previous page exists
- name: previous_page_path
Returns the path to the first page, or <code>nil</code> if none
- name: last_page
description: >-
The path to the previous page, or <code>nil</code> if no previous page exists
The number of the last page, or <code>nil</code> if none
- name: last_page_path
description: >-
Returns the path to the last page, or <code>nil</code> if none
- name: next_page
description: >-
The number of the next page, or <code>nil</code> if no subsequent page exists
- name: next_page_path
description: >-
The path to the next page, or <code>nil</code> if no subsequent page exists
The path to the next page, or <code>nil</code> if no previous page exists
- name: previous_page
description: >-
The number of the previous page, or <code>nil</code> if no previous page exists
- name: previous_page_path
description: >-
The path to the previous page, or <code>nil</code> if no previous page exists


Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
- name: collection
description: >-
<code>Required</code> The collection to paginate
- name: offset
description: >-
<code>Default: 0</code> Supports skipping x number of posts from the beginning of the post list
- name: per_page
description: >-
<code>Default 10</code> Number of resources per page
- name: permalink
description: >-
<code>Default: "/page/:num/"</code> Supports :num as customizable elements
- name: title
description: >-
<code>Default: ":title (Page :num)"</code> Supports :num customizable elements
- name: sort_reverse
description: >-
<code>Default: true</code> Sorts the posts in reverse order
- name: sort_field
description: >-
<code>Default: "date"</code> Sorts the posts by the specified field
- name: limit
description: >-
<code>Default: 0</code> Limits how many content objects to paginate (default: 0, means all)
- name: debug
description: >-
<code>Default: false</code> Turns on debug output for the gem
9 changes: 6 additions & 3 deletions bridgetown-website/src/_docs/content/pagination.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ top_section: Writing Content
category: resources
---

{%@ "docs/help_needed", resource: resource %}

Pagination support is built-in to Bridgetown, but it is not enabled by default. You can enable it in the config file using:

```yml
Expand All @@ -16,7 +14,7 @@ pagination:

## Page Configuration

To facilitate pagination on any given page (like `index.html`, `blog.md`, etc.) then include configuration in the resource's front matter to specify which collection you'd like to paginate through:
To facilitate pagination on any given page (like `index.html`, `blog.md`, etc.) include configuration in the resource's front matter to specify which collection you'd like to paginate through:

``` yml
---
Expand Down Expand Up @@ -53,6 +51,10 @@ paginate:
sort_reverse: true
```

## Attributes for Defining Pagination

{%@ Documentation::VariablesTable data: site.data, scope: :paginator_attr, description_size: :bigger %}

## Excluding a Resource from the Paginator

You can exclude a resource from being included in the paginated items list.
Expand Down Expand Up @@ -89,3 +91,4 @@ To display pagination links, use the `paginator` Liquid object as follows:
The `paginator` Liquid object provides the following attributes:

{%@ Documentation::VariablesTable data: site.data, scope: :paginator, description_size: :bigger %}