Class: Jekyll::Paginate::Categories::Pager

Inherits:
Pager
  • Object
show all
Defined in:
lib/jekyll-paginate-categories/pager.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.paginate_path_category(site, num_page, category_path, paginate_path = site.config['paginate_category_path']) ⇒ Object

Static: Return the pagination path of the page

site - the Jekyll::Site object num_page - the pagination page number paginate_path - the explicit paginate path, if provided

Returns the pagination path as a string



28
29
30
31
32
33
34
# File 'lib/jekyll-paginate-categories/pager.rb', line 28

def self.paginate_path_category(site, num_page, category_path, paginate_path = site.config['paginate_category_path'])
  return nil if num_page.nil?
  return category_path if num_page <= 1
  format = category_path.sub(/(\/)+$/,'') + paginate_path
  format = format.sub(':num', num_page.to_s)
  ensure_leading_slash(format)
end

Instance Method Details

#update_paginate_paths(site, category_path) ⇒ Object

Update paginator.previous_page_path and next_page_path to add category path

site - the Jekyll::Site object category_path - category path, eg /category/web/

Returns nothing.



12
13
14
15
16
17
18
19
# File 'lib/jekyll-paginate-categories/pager.rb', line 12

def update_paginate_paths(site, category_path)
  if @page > 1
    @previous_page_path = category_path.sub(/(\/)+$/,'') + @previous_page_path
  end
  if @page < @total_pages
    @next_page_path = category_path.sub(/(\/)+$/,'') + @next_page_path
  end
end