Add pagination for comments in post content
Summary
- Implements client-side pagination for comments on post pages
- Limits display to 50 comments per page to improve performance on posts with many comments
- Groups main comments (direct replies) with their nested replies on the same page
- Adds Previous/Next buttons and page number navigation with ellipses for many pages
Changes
- Added
paginatedDiscussionStatememo that:- Builds a parent-child comment map for efficient lookup
- Groups main comments with their nested replies
- Paginates with a maximum of 50 comments per page
- Always includes the main post on every page
- Added page navigation UI with Previous/Next buttons and numbered pages
- Resets pagination to page 1 when navigating to a different post
Test plan
-
Open a post with many comments (50+) and verify pagination appears -
Navigate between pages and confirm comments change correctly -
Verify nested comment threads stay together on the same page -
Test sorting options work correctly with pagination -
Navigate to different posts and verify pagination resets to page 1