diff --git a/lib/jekyll-paginate-v2/generator/paginationModel.rb b/lib/jekyll-paginate-v2/generator/paginationModel.rb index 01a106a..62aec9d 100644 --- a/lib/jekyll-paginate-v2/generator/paginationModel.rb +++ b/lib/jekyll-paginate-v2/generator/paginationModel.rb @@ -248,6 +248,13 @@ def paginate(template, config, site_title, all_posts, all_tags, all_categories, end end + intro = nil + if intro_file = config['intro'] + using_posts.delete_if { |post| post.basename =~ /(^|-)#{intro_file}$/ && intro = post } + # Override inherited defaults + intro.data['layout'] = 'none' if !intro.nil? && !intro.data.has_key?('layout') + end + # Calculate the max number of pagination-pages based on the configured per page value total_pages = Utils.calculate_number_of_pages(using_posts, config['per_page']) @@ -289,8 +296,10 @@ def paginate(template, config, site_title, all_posts, all_tags, all_categories, end paginated_page_url = File.join(first_index_page_url, paginated_page_url) + pager_intro = cur_page_nr == 1 ? intro : nil + # 3. Create the pager logic for this page, pass in the prev and next page numbers, assign pager to in-memory page - newpage.pager = Paginator.new( config['per_page'], first_index_page_url, paginated_page_url, using_posts, cur_page_nr, total_pages, indexPageName, indexPageExt) + newpage.pager = Paginator.new( config['per_page'], first_index_page_url, paginated_page_url, using_posts, cur_page_nr, total_pages, indexPageName, indexPageExt, pager_intro) # Create the url for the new page, make sure we prepend any permalinks that are defined in the template page before if newpage.pager.page_path.end_with? '/' diff --git a/lib/jekyll-paginate-v2/generator/paginator.rb b/lib/jekyll-paginate-v2/generator/paginator.rb index 77039c6..239613c 100644 --- a/lib/jekyll-paginate-v2/generator/paginator.rb +++ b/lib/jekyll-paginate-v2/generator/paginator.rb @@ -7,7 +7,7 @@ module PaginateV2::Generator class Paginator attr_reader :page, :per_page, :posts, :total_posts, :total_pages, :previous_page, :previous_page_path, :next_page, :next_page_path, :page_path, :page_trail, - :first_page, :first_page_path, :last_page, :last_page_path + :first_page, :first_page_path, :last_page, :last_page_path, :intro def page_trail @page_trail @@ -19,7 +19,7 @@ def page_trail=(page_array) # Initialize a new Paginator. # - def initialize(config_per_page, first_index_page_url, paginated_page_url, posts, cur_page_nr, num_pages, default_indexpage, default_ext) + def initialize(config_per_page, first_index_page_url, paginated_page_url, posts, cur_page_nr, num_pages, default_indexpage, default_ext, intro = nil) @page = cur_page_nr @per_page = config_per_page.to_i @total_pages = num_pages @@ -60,6 +60,8 @@ def initialize(config_per_page, first_index_page_url, paginated_page_url, posts, @first_page_path = Utils.format_page_number(first_index_page_url, 1, @total_pages) @last_page = @total_pages @last_page_path = Utils.format_page_number(paginated_page_url, @total_pages, @total_pages) + + @intro = intro end # Convert this Paginator's data to a Hash suitable for use by Liquid. @@ -81,7 +83,8 @@ def to_liquid 'first_page_path' => first_page_path, 'last_page' => last_page, 'last_page_path' => last_page_path, - 'page_trail' => page_trail + 'page_trail' => page_trail, + 'intro' => intro } end @@ -108,4 +111,4 @@ def to_liquid end #class PageTrail end # module PaginateV2 -end # module Jekyll \ No newline at end of file +end # module Jekyll