feat(board): default pagination with optional infinite scroll and URL-based page routing

This commit is contained in:
plebeius
2026-02-20 20:16:11 +08:00
parent f660d1a814
commit 60d2f6804d
51 changed files with 775 additions and 82 deletions
+20
View File
@@ -0,0 +1,20 @@
import { useMemo } from 'react';
import type { DirectoryCommunity } from './use-directories';
import { computeGuiPostsPerPage, getBoardFeedPageSizeConstants, type CommunityWithPostsPerPage } from '../lib/utils/board-feed-pagination';
export type BoardFeedPageSize = ReturnType<typeof getBoardFeedPageSizeConstants>;
/**
* Compute board feed page-size values from directory community.
*
* - Single directory board: uses community.features.postsPerPage when valid numeric > 0
* - Missing metadata, non-directory board, /all, /subs, /mod: fallback 15
*
* Returns: guiPostsPerPage, maxGuiPages (10), paginationFeedPostsPerPage, infiniteFeedPostsPerPage
*/
export const useBoardFeedPageSize = (community?: DirectoryCommunity | null): BoardFeedPageSize => {
return useMemo(() => {
const guiPostsPerPage = computeGuiPostsPerPage(community as CommunityWithPostsPerPage | null | undefined);
return getBoardFeedPageSizeConstants(guiPostsPerPage);
}, [community]);
};