[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
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

Suggestion for pagination/"before" documentation: clarify that only js front matter is supported #1334

Open
phlummox opened this issue Feb 17, 2022 · 1 comment

Comments

@phlummox
Copy link

In the documentation for the "before" callback for pagination, it might be worth making explicit that this will only work for "js" front matter:

### The `before` Callback {% addedin "0.10.0" %}
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.

@phlummox
Copy link
Author

... I also just noticed that "before" isn't listed in the "full pagination option list": https://www.11ty.dev/docs/pagination/#full-pagination-option-list

Adding it and mentioning that its datatype is "function" might be a good idea, in addition to making the "before" section more explicit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant