Add pagination + update layout of followers

This commit is contained in:
Gabe Kangas
2022-01-24 14:24:43 -08:00
parent 59f9299b6a
commit 8943be9bf9
3 changed files with 67 additions and 9 deletions

View File

@@ -197,3 +197,17 @@ export function checkUrlPathForDisplay() {
}
return null;
}
export function paginateArray(items, page, perPage) {
const offset = perPage * (page - 1);
const totalPages = Math.ceil(items.length / perPage);
const paginatedItems = items.slice(offset, perPage * page);
return {
previousPage: page - 1 ? page - 1 : null,
nextPage: totalPages > page ? page + 1 : null,
total: items.length,
totalPages: totalPages,
items: paginatedItems,
};
}