Sha256: df4016203c84eae9078e1885e1b79aa796e747c02dc55eada04219581fad8302
Contents?: true
Size: 951 Bytes
Versions: 27
Compression:
Stored size: 951 Bytes
Contents
# See the Pagy documentation: https://ddnexus.github.io/pagy/extras/trim # frozen_string_literal: true class Pagy # :nodoc: DEFAULT[:trim_extra] = true # extra enabled by default # Remove the page=1 param from the first page link module TrimExtra # Override the original pagy_link_proc. # Call the pagy_trim method if the trim_extra is enabled. def pagy_link_proc(pagy, link_extra: '') link_proc = super(pagy, link_extra: link_extra) return link_proc unless pagy.vars[:trim_extra] lambda do |page, text = pagy.label_for(page), extra = ''| link = +link_proc.call(page, text, extra) return link unless page == 1 pagy_trim(pagy, link) end end # Remove the the :page_param param from the first page link def pagy_trim(pagy, link) link.sub!(/[?&]#{pagy.vars[:page_param]}=1\b(?!&)|\b#{pagy.vars[:page_param]}=1&/, '') end end Frontend.prepend TrimExtra end
Version data entries
27 entries across 27 versions & 1 rubygems