Sha256: 6372f107088f804c6a441b278d4e5cf31f756c3adb67a411945733ab421924d4

Contents?: true

Size: 495 Bytes

Versions: 2

Compression:

Stored size: 495 Bytes

Contents

# See the Pagy documentation: https://ddnexus.github.io/pagy/extras/trim
# encoding: utf-8
# frozen_string_literal: true

class Pagy

  module Trim
    def pagy_link_proc(pagy, link_extra='')
      link_proc = super(pagy, link_extra)
      re = /[?&]#{pagy.vars[:page_param]}=1\b(?!&)|\b#{pagy.vars[:page_param]}=1&/
      lambda do |n, text=n, extra=''|
        link = link_proc.call(n, text, extra)
        n == 1 ? link.sub(re, '') : link
      end
    end
  end
  Frontend.prepend Trim

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pagy-4.1.0 lib/pagy/extras/trim.rb
pagy-4.0.0 lib/pagy/extras/trim.rb