master @ 28 LINES
[ HISTORY ] [ UP ]
┌─ ASTRO ────────────────────────────────────────────────────────────────────┐
│ --- │
│ import Pre from "../Pre/Pre.astro"; │
│ import { paginationItems, type Props } from "./Pagination"; │
│ import "./Pagination.scss"; │
│ │
│ const { current, total, href } = Astro.props as Props; │
│ const items = paginationItems(current, total); │
│ const prev = current > 1 ? href(current - 1) : null; │
│ const next = current < total ? href(current + 1) : null; │
│ --- │
│ {total > 1 && ( │
│ <nav class="pager" aria-label="Pagination"> │
│ <Pre>{prev │
│ ? <a class="pager-arrow" href={prev} aria-label="Previous page">{"[ < ]"}</a │
│ > │
│ : <span class="pager-arrow disabled">{"[ < ]"}</span> │
│ }{" "}{items.map((it, i) => ( │
│ <Fragment>{i > 0 ? " " : ""}{ │
│ it.kind === "gap" ? <span class="pager-gap">...</span> │
│ : it.current ? <span class="pager-current" aria-current="page">[{it.n}]</s │
│ pan> │
│ : <a class="pager-page" href={href(it.n)}>{it.n}</a> │
│ }</Fragment> │
│ ))}{" "}{next │
│ ? <a class="pager-arrow" href={next} aria-label="Next page">{"[ > ]"}</a> │
│ : <span class="pager-arrow disabled">{"[ > ]"}</span> │
│ }</Pre> │
│ </nav> │
│ )} │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ ASTRO ──────────────────────────────┐
│ --- │
│ import Pre from "../Pre/Pre.astro"; │
│ import { paginationItems, type Props } from │
│ "./Pagination"; │
│ import "./Pagination.scss"; │
│ │
│ const { current, total, href } = Astro.props │
│ as Props; │
│ const items = paginationItems(current, total │
│ ); │
│ const prev = current > 1 ? href(current - 1) │
│ : null; │
│ const next = current < total ? href(current │
│ + 1) : null; │
│ --- │
│ {total > 1 && ( │
│ <nav class="pager" aria-label="Pagination" │
│ > │
│ <Pre>{prev │
│ ? <a class="pager-arrow" href={prev} a │
│ ria-label="Previous page">{"[ < ]"}</a> │
│ : <span class="pager-arrow disabled">{ │
│ "[ < ]"}</span> │
│ }{" "}{items.map((it, i) => ( │
│ <Fragment>{i > 0 ? " " : ""}{ │
│ it.kind === "gap" ? <span class="pag │
│ er-gap">...</span> │
│ : it.current ? <span class="pager-cu │
│ rrent" aria-current="page">[{it.n}]</span> │
│ : <a class="pager-page" href={href(i │
│ t.n)}>{it.n}</a> │
│ }</Fragment> │
│ ))}{" "}{next │
│ ? <a class="pager-arrow" href={next} a │
│ ria-label="Next page">{"[ > ]"}</a> │
│ : <span class="pager-arrow disabled">{ │
│ "[ > ]"}</span> │
│ }</Pre> │
│ </nav> │
│ )} │
└──────────────────────────────────────────────┘
──────────────────────────────────────────────────────────────────────────────────────
OOKNET
────────────────────────────────────────────────
OOKNET