class Bridgetown::Paginate::PaginationPage
This page handles the creation of the fake pagination pages based on the original page configuration. The code does the same things as the default Bridgetown
page.rb code but just forces the code to look into the template instead of the (currently non-existing) pagination page. This page exists purely in memory and is not read from disk
Public Class Methods
new(page_to_copy, cur_page_nr, total_pages, index_pageandext, template_ext)
click to toggle source
# File lib/bridgetown-paginate/pagination_page.rb, line 14 def initialize(page_to_copy, cur_page_nr, total_pages, index_pageandext, template_ext) @site = page_to_copy.site @base = "" @url = "" @name = index_pageandext.nil? ? "index#{template_ext}" : index_pageandext @path = page_to_copy.path # Creates the basename and ext member values process(@name) # Only need to copy the data part of the page as it already contains the # layout information self.data = Bridgetown::Utils.deep_merge_hashes page_to_copy.data, {} self.content = page_to_copy.content # Store the current page and total page numbers in the pagination_info construct data["pagination_info"] = { "curr_page" => cur_page_nr, "total_pages" => total_pages } # Perform some validation that is also performed in Bridgetown::Page validate_data! page_to_copy.path validate_permalink! page_to_copy.path Bridgetown::Hooks.trigger :pages, :post_init, self end
Public Instance Methods
set_url(url_value)
click to toggle source
rubocop:disable Naming/AccessorMethodName
# File lib/bridgetown-paginate/pagination_page.rb, line 40 def set_url(url_value) @path = url_value.delete_prefix "/" @dir = File.dirname(@path) @url = url_value end