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

Improve Dynamic Slugs documentation. #1489

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Improve Dynamic Slugs documentation. #1489

wants to merge 1 commit into from

Conversation

dwkns
Copy link
Contributor

@dwkns dwkns commented Oct 28, 2022

Improve description of how Dynamic Slugs to Subset Your Pagination works. See: 11ty/eleventy#2544

It wasn't clear (to me) that you have to use an Object for your pagination data. Typically a CMS will return an array rather than an object and that produces weird results.

Improve description of how Dynamic Slugs to Subset Your Pagination works.
See: 11ty/eleventy#2544

It wasn't clear  (to me) that you have to use an `Object` for your pagination data. Typically a CMS will return an array rather than an object and that produces weird results.
1. Via `pagination.alias`, your template now has access to `author.name` and `author.content` for `"zachleat"`
1. And as `pagination.size` is set to 1, the pagination only operates on that one selected page for rendering.

{% callout "info", "md" %}You have to use an object for your pagination data. If you use an array you will get unexpected results.{% endcallout %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this line true? You can’t use /authors/0/ to fetch [{ name: "", … }]?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so.

If your posts object is an array, you can use /authors/0/ to fetch the first post, but that probably isn't very helpful.

You almost certainly want to match a serverless url against a full slug name and not just a numeric value.

Working repo here:
https://github.com/dwkns/eleventy-serverless-demo

@zachleat zachleat added the open-question Further information is requested from the original poster. label Feb 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-question Further information is requested from the original poster.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants