Define own chunking pagination function using JS (with variable chunk size) #4036
Replies: 6 comments
|
@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. |
|
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. |
|
@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… 😅 |
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
|
Some interesting notes on #2507 around a minimum chunk size for the last page (reminds me of CSS |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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
slicecallback could replace thesizeattribute (I don't see how they could co-exist), and be run after the newbeforecallback.So, instead of spliting
["item1", "item2", "item3", "item4"]into[["item1", "item2"], ["item3", "item4"]](withsize: 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: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.
All reactions