Add pagination to comments to prevent browser crash
Summary
Closes #720 (closed) - Fix browser crash with 1000+ comments
Changes
- Limit initial render to 50 root-level comments (prevents browser crash)
- Add "Show more comments" button for loading additional comments
- Add visible pagination links for crawler accessibility (
?comments_page=2&sort=trending#comments) - Create
/api/comments/[author]/[permlink]route with in-memory caching (60s TTL) - Support URL-based navigation for bookmarkable/shareable comment pages
How It Works
- Browser users: Click "Show more" for smooth loading (no page reload)
-
Crawlers: Follow visible
<a href>links to discover all comments -
Direct URLs:
?comments_page=2loads page 2 directly via SSR
Testing
-
Open https://blog.openhive.network/hive-125125/@ecency.waves/waves-20251102jlybmw (1962 comments) -
Verify page loads without "Aw, Snap!" crash -
Verify "Show more comments" button works -
Verify pagination link appears below button -
Test ?comments_page=2 loads page 2 directly -
Test normal posts (no regression)
API Investigation
Tested Hive APIs for native pagination - none available on public nodes:
-
database_api.list_comments- NOT available -
get_content_replies- times out on large posts -
bridge.get_discussion- works but returns all comments
Solution: Fetch all via get_discussion, cache on server, return paginated slices.
Edited by gandalf_automation