Skip to content

Commit

Permalink
Hide pagination buttons when not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
svemat01 committed Sep 16, 2023
1 parent 3e552c8 commit 43e3d28
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions blog/src/components/PageButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export const PageButtons = ({
hrefPrefix = '',
...properties
}: Properties) => {
if (total <= 1) {
return;
}

const maxPerSide = Math.floor(max / 2);
const start = Math.max(
Math.min(Math.max(current - maxPerSide, 1), total - max + 1),
Expand Down

0 comments on commit 43e3d28

Please sign in to comment.