diff --git a/src/content/docs/en/guides/routing.mdx b/src/content/docs/en/guides/routing.mdx index 3d73381673093..e7ba383ea70fb 100644 --- a/src/content/docs/en/guides/routing.mdx +++ b/src/content/docs/en/guides/routing.mdx @@ -431,23 +431,26 @@ Paginated route names should use the same `[bracket]` syntax as a standard dynam You can use the `paginate()` function to generate these pages for an array of values like so: -```astro /{ (paginate) }/ /paginate\\(.*\\);/ /(?<=const.*)(page)/ /page\\.[a-zA-Z]+/ +```astro title="src/pages/astronauts/[page].astro" /{ (paginate) }/ /paginate\\(.*\\);/ /(?<=const.*)(page)/ /page\\.[a-zA-Z]+/ --- -// src/pages/astronauts/[page].astro -export function getStaticPaths({ paginate }) { +import type { GetStaticPaths } from "astro"; + +export const getStaticPaths = (({ paginate }) => { const astronautPages = [ { astronaut: "Neil Armstrong" }, { astronaut: "Buzz Aldrin" }, { astronaut: "Sally Ride" }, { astronaut: "John Glenn" }, ]; - + // Generate pages from our array of astronauts, with 2 to a page return paginate(astronautPages, { pageSize: 2 }); -} +}) satisfies GetStaticPaths; + // All paginated data is passed on the "page" prop const { page } = Astro.props; --- +

Page {page.currentPage}