2020.destroytoday.com

Pagination

Now that I’ve written more than a dozen articles, this page is starting to feel incredibly long, which makes it the perfect time to think about pagination. In Contentful, the API request I use to retrieve entries takes skip and limit parameters to paginate the results. In an effort to embrace the metric system (while biting my thumb at the imperial system), I’ve limited pages to 10 articles. I originally considered a classic sidebar of month-based categories (alongside a blogroll of my friends), but didn’t want to fall victim to the 1-article months that shame you for not writing as consistently as you thought you would.

To persist the pagination, I’m using a 1-based page query parameter. Then, in my Contentful request, I set the skip parameter to ($route.query.page - 1) * limit. Since the site is universal, navigating between pages is lightning quick, which makes me wonder if it’s worth implementing a smoother transition at some point. I typically hate transitions between pages, but this might be on opportunity to improve the UX rather than snapping to the top. At the very least, this initial barebones implementation provides plenty of room for tweaking.