Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Pagination]: Option to generate <a> instead of <button> #1478

Closed
Youhan opened this issue Mar 5, 2024 · 3 comments · Fixed by #1682
Closed

[Pagination]: Option to generate <a> instead of <button> #1478

Youhan opened this issue Mar 5, 2024 · 3 comments · Fixed by #1682
Labels
enhancement New feature or request

Comments

@Youhan
Copy link
Contributor

Youhan commented Mar 5, 2024

Description

The <UPagination generates <button> elements and attaches an on-click event handler to update the page v-model.
One shortcoming with the is that when you nuxt generate, the Nitro crawler does not see the pagination links and can't follow them, leading to only the first page being generated (or at least that's my understanding). I think that would be same issue with Google bots not being able to identify pagination links.

The feature I am requesting is to add a prop or a few props that work together to add the functionality to generate <a>s instead of <button>s with corresponding pathname or query params.

Now, there are 2 ways I can think someone would implement pagination in the URL.

  1. query params: /category/catname?page=4
  2. pathname: /category/catname/4

Thought?

Additional context

No response

@Youhan Youhan added the enhancement New feature or request label Mar 5, 2024
@Youhan Youhan changed the title [Pagination]: Option to generate <a> instead of <button> [Pagination]: Option to generate <a> instead of <button> Mar 5, 2024
@Youhan
Copy link
Contributor Author

Youhan commented Mar 5, 2024

I think it would be nice to migrate from <button to <a for all cases but the <UButton would need the correct href (or to)

@Youhan
Copy link
Contributor Author

Youhan commented Mar 5, 2024

Possible solution could be to expose a slot with props to give control to the user on how they want to render the links.

@hddhyq
Copy link

hddhyq commented Mar 26, 2024

@benjamincanac I noticed that UButton supports the link mode by default. I want to create a PR for this issue to add more properties support for UButton in Pagination. Like doing it as follows:

<UPagination 
  v-model="page" 
  :page-count="5" 
  :total="items.length" 
  :link="{
    to: (page) => `/category/catname?page=${page}`
    _target="_self"
  }" />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants