FEATURE: Add pagination to categories page (#23976)

When `lazy_load_categories` is enabled, the categories are no longer
preloaded in the `Site` object, but instead they are being requested
on a need basis.

The categories page still loaded all categories at once, which was not
ideal for sites with many categories because ti would take a lot of
time to build and parse the response.

This commit adds pagination to the categories page using the LoadMore
helper. As the user scrolls through the categories page, more categories
are requested from the server and appended to the page.

<!-- NOTE: All pull requests should have tests (rspec in Ruby, qunit in JavaScript). If your code does not include test coverage, please include an explanation of why it was omitted. -->
This commit is contained in:
Bianca Nenciu
2023-12-11 17:58:45 +02:00
committed by GitHub
parent af23fec835
commit 81b0420614
6 changed files with 89 additions and 40 deletions

View File

@@ -47,6 +47,7 @@ class CategoriesController < ApplicationController
include_topics: include_topics(parent_category),
include_subcategories: include_subcategories,
tag: params[:tag],
page: params[:page],
}
@category_list = CategoryList.new(guardian, category_options)
@@ -407,6 +408,7 @@ class CategoriesController < ApplicationController
is_homepage: current_homepage == "categories",
parent_category_id: params[:parent_category_id],
include_topics: false,
page: params[:page],
}
topic_options = { per_page: CategoriesController.topics_per_page, no_definitions: true }