pagination(
page:,
pages:,
url:, # ->(page) { url }
label: "Paginação"
)
url is a lambda from a page number to its URL, so it works with any pagination source (pagy, limit/offset, your own). It shows the first and last pages and two pages around the current one; with a single page it renders nothing.
<%= stack(gap: "12px") do %>
<%= pagination page: 1, pages: 3, url: ->(page) { "?page=#{page}" } %>
<%= pagination page: 7, pages: 24, url: ->(page) { "?page=#{page}" } %>
<% end %>