You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The most powerful tool to change the data. Use this callback to modify, filter, or otherwise change the pagination data however you see fit *before* pagination occurs.
{% raw %}
```markdown
---js
{
pagination: {
data: "testdata",
size: 2,
before: function(data) {
return data.map(entry => `${entry} with a suffix`);
}
},
testdata: [
"item1",
"item2",
"item3",
"item4"
]
}
It may not be obvious to a reader that the "before" value of the front-matter here is a literal javascript function (rather than, say, a string that gets evaluated as javascript), and that therefore no other front-matter format besides "js" will work. (At least, I assume such is the case, from experimenting a little.)
It's true that a reader can perhaps infer this from the fact that the other examples on the page don't use js and this one does, or work it out with some trial and error: but people often read documentation in a hurry, so I think it's worth making this explicit.
The text was updated successfully, but these errors were encountered:
In the documentation for the "before" callback for pagination, it might be worth making explicit that this will only work for "js" front matter:
11ty-website/src/docs/pagination.md
Lines 452 to 473 in c3fd39c
It may not be obvious to a reader that the "before" value of the front-matter here is a literal javascript function (rather than, say, a string that gets evaluated as javascript), and that therefore no other front-matter format besides "js" will work. (At least, I assume such is the case, from experimenting a little.)
It's true that a reader can perhaps infer this from the fact that the other examples on the page don't use js and this one does, or work it out with some trial and error: but people often read documentation in a hurry, so I think it's worth making this explicit.
The text was updated successfully, but these errors were encountered: