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

Let me define my own pagination function using JS #772

Closed
nhoizey opened this issue Nov 15, 2019 · 5 comments
Closed

Let me define my own pagination function using JS #772

nhoizey opened this issue Nov 15, 2019 · 5 comments
Labels
enhancement needs-votes A feature request on the backlog that needs upvotes or downvotes. Remove this label when resolved.

Comments

@nhoizey
Copy link
Contributor

nhoizey commented Nov 15, 2019

Is your feature request related to a problem? Please describe.

I really don't like paginations using decimal increments, because every time I add new content, all these pages have changing content, while old archive pages should be really stable, both for SEO and UX (bookmarks for example).

I prefer archives per years and/or months.

Describe the solution you'd like

Being able to define my own JS function to slice the paginated data based on the date would allow that.

A slice callback could replace the size attribute (I don't see how they could co-exist), and be run after the new before callback.

So, instead of spliting ["item1", "item2", "item3", "item4"] into [["item1", "item2"], ["item3", "item4"]] (with size: 2), it would allow me to split ["2018-07-12-article1", "2018-12-13-article2", "2018-12-15-article3", "2019-03-23-article4"] into this for month pages:

[
  ["2018-07-12-article1"],
  ["2018-12-13-article2", "2018-12-15-article3"],
  ["2019-03-23-article4"]
]

I could then (I guess, maybe not) use the date of the first item in each slice to define the permalink.

Describe alternatives you've considered

The only other I can imagine right now is creating actual templates for each month/year I have published content (quite a lot, since 2001), and filter the content collections for each.

It would be really cumbersome to initialize, and it requires a new page every month.

@edwardhorsford
Copy link
Contributor

@nhoizey I've made year and month collections (see an example here) - you can do it with custom collections.

You use a custom collection to create groups of items sliced how you like. You can then pass this collection to pagination to generate the individual pages.

I posted the code I use to do this in this thread.

@zachleat
Copy link
Member

Oh dang I like this idea. Practically speaking this would allow me to easily add a Day view to my Twitter archive (browse by tweets day) that I really like.

@nhoizey
Copy link
Contributor Author

nhoizey commented Nov 15, 2019

@edwardhorsford awesome, I'll check that right now! 👍

@zachleat good idea, I also plan to get all my tweets on my site, and daily view will be interesting, because I have quite a few… 😅

@zachleat zachleat added the needs-votes A feature request on the backlog that needs upvotes or downvotes. Remove this label when resolved. label Dec 1, 2019
@zachleat
Copy link
Member

zachleat commented Dec 1, 2019

This repository is now using lodash style issue management for enhancements. This means enhancement issues will now be closed instead of leaving them open.

View the enhancement backlog here. Don’t forget to upvote the top comment with 👍!

@zachleat zachleat closed this as completed Dec 1, 2019
@zachleat
Copy link
Member

zachleat commented Dec 1, 2019

(putting this into the queue)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement needs-votes A feature request on the backlog that needs upvotes or downvotes. Remove this label when resolved.
Projects
None yet
Development

No branches or pull requests

3 participants