---
import { type Page } from 'astro';
interface Props {
page: Page;
paginationOffset?: number;
urlPattern: string;
}
const { page, urlPattern, paginationOffset = 3 } = Astro.props;
const pages = [];
const lowerEnd = Math.max(page.currentPage - paginationOffset, 1);
const highEnd = Math.min(page.currentPage + paginationOffset, page.lastPage);
const generateUrl = (index: number) => {
return urlPattern.replace('{}', index.toString());
};
for (let index = lowerEnd; index <= highEnd; index++) {
pages.push({
index,
url: generateUrl(index),
});
}
---