Skip to content

Commit

Permalink
Hide pagination buttons when not needed (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
svemat01 authored Sep 29, 2023
1 parent 3e552c8 commit df3e38e
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 df3e38e

Please sign in to comment.