Overwrite/Define pagination paths #162
danilopolani
started this conversation in
Proposal
Replies: 1 comment
-
If I use Edit: I also find this discussion #19 is about the same idea. If we make the first page in |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
A common scenario with pagination is that the first page is the homepage (e.g.
https://example.com
) and, from page 2, the URL changes to a different path, (e.g.https://example.com/page/2
) and with Astro this is not currently possible.Current workaround
page/[page].astro
file where I place the real pagination;Astro.props
is the first page, add a<script>
with a redirect to the homepage;page.prev
fromAstro.props
is the first page, use/
as URL.Proposed solution
We could have a callback in the
paginate
function that mutates the pagination URLs (similar to 11ty where we can define the pagination permalink). With this we could use thepaginate()
directly from the homepage and then, in the[page].astro
file, just retrieve the current page and its props.I have to admit this could be a bit "over" as solution, but it's definitely the most complete and versatile. Another solution could be just to overwrite the first page URL, but then in the homepage you still would manually check for more items, create the pagination link etc.
Beta Was this translation helpful? Give feedback.
All reactions