Skip to content

Commit

Permalink
11ty/eleventy#2466 Add documentation for skip in pagination
Browse files Browse the repository at this point in the history
The referenced PR adds the skip parameter and this one adds the required documentation.

The "addedin" will probably need to be updated once the referenced PR got merged.

Signed-off-by: Raphael Höser <[email protected]>
  • Loading branch information
Snapstromegon committed Jun 29, 2022
1 parent 171806f commit 89058e0
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/docs/pagination.md
Original file line number Diff line number Diff line change
Expand Up @@ -723,13 +723,46 @@ The above will iterate over a data set containing: `["item1 with a suffix", "ite

You can do anything in this `before` callback. Maybe a custom `.sort()`, `.filter()`, `.map()` to remap the entries, `.slice()` to paginate only a subset of the data, etc!

### Skipping Items {% addedin "2.0.0" %}

Sometimes you might want to skip some of the first items in your data (e.g. because you already show them somewhere else).

{% codetitle "YAML Front Matter", "Syntax" %}

```markdown
---
pagination:
data: testdata
size: 2
skip: 1
testdata:
- item1
- item2
- item3
- item4
- item5
---
```

Paginates to:

{% codetitle "JavaScript Object", "Syntax" %}

```js
[
[ "item2", "item3" ],
[ "item4", "item5" ],
]
```

### Order of Operations

If you use more than one of these data set modification features, here’s the order in which they operate:

* The `before` callback
* `reverse: true`
* `filter` entries
* `skip` entries

## Add All Pagination Pages to Collections {% addedin "0.8.0" %}

Expand Down

0 comments on commit 89058e0

Please sign in to comment.