From 050e982006feaad46ddc83743ca06287957c5a64 Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Sun, 5 May 2013 17:26:29 +0200 Subject: [PATCH] Add extra question to ensure that the index.html file is in thepagination path's directory --- lib/jekyll/generators/pagination.rb | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/jekyll/generators/pagination.rb b/lib/jekyll/generators/pagination.rb index a0e8b819..0cd934c5 100644 --- a/lib/jekyll/generators/pagination.rb +++ b/lib/jekyll/generators/pagination.rb @@ -69,9 +69,19 @@ module Jekyll # # Returns true if pagination is enabled, false otherwise. def self.pagination_enabled?(config, page) - page.name == 'index.html' && - !config['paginate'].nil? && - File.dirname(config['paginate_path']) == page.dir + !config['paginate'].nil? && + page.name == 'index.html' && + subdirectories_identical(config['paginate_path'], page.dir) + end + + # Determine if the subdirectories of the two paths are the same relative to source + # + # paginate_path - the paginate_path configuration setting + # page_dir - the directory of the Jekyll::Page + # + # Returns whether the subdirectories are the same relative to source + def self.subdirectories_identical(paginate_path, page_dir) + File.dirname(paginate_path).gsub(/\A\./, '') == page_dir.gsub(/\/\z/, '') end # Static: Return the pagination path of the page