import * as preact from "preact"; import { textLinkPrevious, textLinkNext } from "./translation"; /** @jsx preact.h */ export default function Pagination({ counter, start, settings, onPageSelect }) { const pages = Math.ceil(counter / settings.show); const page = start / settings.show; let displayedPages; if (page <= 2) { // Display max three pages displayedPages = Math.min(pages, 3); } else { // Display two more pages, but don't overflow displayedPages = Math.min(pages, page + 2); } const items = []; for (let f = 0; f < displayedPages; f++) { if (f === page) { items.push(
  • {f + 1}
  • ); } else { items.push(
  • onPageSelect(f * settings.show)} > {f + 1}
  • ); } } return (
    ); }