Module: Paginator::LinkHelpers
- Defined in:
- lib/middleman/paginator/link_helpers.rb
Instance Method Summary collapse
- #first_page_link(text: 'First', **options) ⇒ Object
- #last_page_link(text: 'Last', **options) ⇒ Object
- #next_page_link(text: 'Next', **options) ⇒ Object
- #pages(count: 5) ⇒ Object
- #previous_page_link(text: 'Previous', **options) ⇒ Object
Instance Method Details
#first_page_link(text: 'First', **options) ⇒ Object
33 34 35 36 37 |
# File 'lib/middleman/paginator/link_helpers.rb', line 33 def first_page_link(text: 'First', **) path = "#{@locs[:paginator][:destination]}index.html" link_to text, path, ** end |
#last_page_link(text: 'Last', **options) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/middleman/paginator/link_helpers.rb', line 25 def last_page_link(text: 'Last', **) page = @locs[:paginator][:last_page] path = "#{@locs[:paginator][:destination]}pages/#{page + 1}.html" link_to text, path, ** end |
#next_page_link(text: 'Next', **options) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/middleman/paginator/link_helpers.rb', line 17 def next_page_link(text: 'Next', **) page = @locs[:paginator][:page] path = "#{@locs[:paginator][:destination]}pages/#{page + 1}.html" return unless sitemap.find_resource_by_path(path) link_to text, path, ** end |
#pages(count: 5) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/middleman/paginator/link_helpers.rb', line 39 def pages(count: 5) pages_group = Paginator::PagesGroup.new( current: @locs[:paginator][:page], last: @locs[:paginator][:last_page], count: count ) pages_group.generate do |page_number| page_name = page_number == 1 ? 'index.html' : "pages/#{page_number}.html" path = @locs[:paginator][:destination] + page_name yield(page_number, path) end end |
#previous_page_link(text: 'Previous', **options) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/middleman/paginator/link_helpers.rb', line 4 def previous_page_link(text: 'Previous', **) page = @locs[:paginator][:page] return if page == 1 path = if page == 2 "#{@locs[:paginator][:destination]}index.html" else "#{@locs[:paginator][:destination]}pages/#{page - 1}.html" end link_to text, path, ** end |