I have a static site with a blog section using Astro's built-in pagination, doing something like this in src/pages/blog/[page].astro
:
export const itemsPerPage = 12
export async function getStaticPaths({ paginate }) {
const allBlogs = await Astro.glob('./*.md')
return paginate(allBlogs, { pageSize: itemsPerPage })
}
const { page } = Astro.props
const { start, end, total, data, currentPage } = page
The page
props are then used to populate the pagination UI. This all works fine, and results in /blog/1
, /blog/2
etc pages being built.
What I would like to do is have src/pages/blog/index.astro
to generate /blog
, which would have the same content as the first page e.g. /blog/1
. I can replicate the logic to get the posts, but I can't figure out how to access the pagination data outside of getStaticPaths
. Is there a way to do this?