From ea71036e8ccc20b42037a07f307adcdb469a34c9 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Sun, 5 May 2013 15:40:13 +0200 Subject: [PATCH] Paginate in subdirectories properly. Fixes #878. --- lib/jekyll/generators/pagination.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/jekyll/generators/pagination.rb b/lib/jekyll/generators/pagination.rb index 71e27fba..a0e8b819 100644 --- a/lib/jekyll/generators/pagination.rb +++ b/lib/jekyll/generators/pagination.rb @@ -11,7 +11,7 @@ module Jekyll # Returns nothing. def generate(site) site.pages.dup.each do |page| - paginate(site, page) if Pager.pagination_enabled?(site.config, page.name) + paginate(site, page) if Pager.pagination_enabled?(site.config, page) end end @@ -65,11 +65,13 @@ module Jekyll # Determine if pagination is enabled for a given file. # # config - The configuration Hash. - # file - The String filename of the file. + # page - The Jekyll::Page with which to paginate # # Returns true if pagination is enabled, false otherwise. - def self.pagination_enabled?(config, file) - file == 'index.html' && !config['paginate'].nil? + def self.pagination_enabled?(config, page) + page.name == 'index.html' && + !config['paginate'].nil? && + File.dirname(config['paginate_path']) == page.dir end # Static: Return the pagination path of the page @@ -80,7 +82,7 @@ module Jekyll # Returns the pagination path as a string def self.paginate_path(site_config, num_page) return nil if num_page.nil? || num_page <= 1 - format = site_config['paginate_path'] + format = File.basename(site_config['paginate_path']) format.sub(':num', num_page.to_s) end