Pagination: Add page.url.first, page.url.last to the Page interface #862
regisphilibert
started this conversation in
Proposal
Replies: 2 comments 1 reply
-
Sounds like a good idea to me! |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hi. I opened a PR for this. withastro/astro#11176 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
Adding two new keys to the
page.url
object of the pagination's Page interface.page.url.first
would return the url of the first page.page.url.last
would return the url of the last page.Background & Motivation
Currently when building your own navigation, one must determine what is the first page url in order to build the list of links pointing to various pages. This url can be
/post/
or/post/category/art/
or/post/category/art/1
etc...This determination can only be worked from
page.url.current
and involves several checks and conditions so that the proper "first page url" is retrieved and validated. For example this is currently what I need to do in order to build basicfirstUrl
andlastUrl
.There might be a simpler alternative which I missed out, but I believe this illustrates the time and efforts that this RFP could save for users.
Goals
Example
This would greatly simplify the building of any pagination links. Compare the following with the code shared above.
I feel like the naming of the keys follow the convention in use but any suggestion is welcome.
Beta Was this translation helpful? Give feedback.
All reactions