module Pagy::Frontend

def pagy_nav(pagy, pagy_id: nil, link_extra: '',

Generic pagination: it returns the html with the series of links to the pages
def pagy_nav(pagy, pagy_id: nil, link_extra: '',
             nav_aria_label: nil, nav_i18n_key: nil, **vars)
  p_id = %( id="#{pagy_id}") if pagy_id
  link = pagy_link_proc(pagy, link_extra:)
  html = +%(<nav#{p_id} class="pagy-nav pagination" #{nav_aria_label_attr(pagy, nav_aria_label, nav_i18n_key)}>)
  html << prev_html(pagy, link)
  pagy.series(**vars).each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
    html << case item
            when Integer
              %(<span class="page">#{link.call(item)}</span> )
            when String
              %(<span class="page active">) +
              %(<a role="link" aria-disabled="true" aria-current="page">#{pagy.label_for(item)}</a></span> )
            when :gap
              %(<span class="page gap">#{pagy_t('pagy.gap')}</span> )
            else
              raise InternalError, "expected item types in series to be Integer, String or :gap; got #{item.inspect}"
            end
  end
  html << %(#{next_html(pagy, link)}</nav>)
end