# See the Pagy documentation: https://ddnexus.github.io/pagy/docs/extras/semantic # frozen_string_literal: true require 'pagy/extras/js_tools' class Pagy # :nodoc: # Frontend modules are specially optimized for performance. # The resulting code may not look very elegant, but produces the best benchmarks module SemanticExtra # Pagination for semantic: it returns the html with the series of links to the pages def pagy_semantic_nav(pagy, id: nil, aria_label: nil, **vars) id = %( id="#{id}") if id a = pagy_anchor(pagy) html = %(
) end # Javascript pagination for semantic: it returns a nav with a data-pagy attribute used by the pagy.js file def pagy_semantic_nav_js(pagy, id: nil, aria_label: nil, **vars) sequels = pagy.sequels(**vars) id = %( id="#{id}") if id a = pagy_anchor(pagy) tokens = { 'before' => semantic_prev_html(pagy, a), 'a' => a.(PAGE_TOKEN, LABEL_TOKEN, classes: 'item'), 'current' => %(#{LABEL_TOKEN}), 'gap' => %(