diff --git a/src/components/Pagenation/index.astro b/src/components/Pagenation/index.astro new file mode 100644 index 0000000..00cdcd8 --- /dev/null +++ b/src/components/Pagenation/index.astro @@ -0,0 +1,96 @@ +--- +import { pipe } from 'remeda'; + +interface Props { + page: number; + pageNum: number; + getPagePath: (n: number) => string; +} +const { page, pageNum, getPagePath } = Astro.props; + +const N = 2; + +const visiblePageNums = pipe(null, () => { + const min = page - N < 1 ? 1 : page - N; + const max = page + N > pageNum ? pageNum : page + N; + return Array.from({ length: max - min + 1 }, (_, i) => min + i); +}); +--- + +
+ +