Fix Pager.in_hierarchy to actually do the right thing
This commit is contained in:
parent
05218711b2
commit
7dc6767bc9
|
@ -107,26 +107,30 @@ module Jekyll
|
||||||
# Page's name must be `index.html` and exist in any of the directories
|
# Page's name must be `index.html` and exist in any of the directories
|
||||||
# between the site source and `paginate_path`.
|
# between the site source and `paginate_path`.
|
||||||
#
|
#
|
||||||
|
# config - the site configuration hash
|
||||||
|
# page - the Jekyll::Page about which we're inquiring
|
||||||
|
#
|
||||||
# Returns true if the
|
# Returns true if the
|
||||||
def self.pagination_candidate?(config, page)
|
def self.pagination_candidate?(config, page)
|
||||||
page_dir = File.dirname(File.expand_path(remove_leading_slash(page.path), config['source']))
|
page_dir = File.dirname(File.expand_path(remove_leading_slash(page.path), config['source']))
|
||||||
|
paginate_path = remove_leading_slash(config['paginate_path'])
|
||||||
|
paginate_path = File.expand_path(paginate_path, config['source'])
|
||||||
page.name == 'index.html' &&
|
page.name == 'index.html' &&
|
||||||
in_hierarchy(config, page_dir)
|
in_hierarchy(config['source'], page_dir, File.dirname(paginate_path))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Determine if the subdirectories of the two paths are the same relative to source
|
# Determine if the subdirectories of the two paths are the same relative to source
|
||||||
#
|
#
|
||||||
# config - the site configuration hash
|
# source - the site source
|
||||||
# page_dir - the directory of the Jekyll::Page
|
# page_dir - the directory of the Jekyll::Page
|
||||||
|
# paginate_path - the absolute paginate path (from root of FS)
|
||||||
#
|
#
|
||||||
# Returns whether the subdirectories are the same relative to source
|
# Returns whether the subdirectories are the same relative to source
|
||||||
def self.in_hierarchy(config, page_dir)
|
def self.in_hierarchy(source, page_dir, paginate_path)
|
||||||
paginate_path = remove_leading_slash(config['paginate_path'])
|
return false if paginate_path == File.dirname(paginate_path)
|
||||||
paginate_path = File.expand_path(paginate_path, config['source'])
|
return false if paginate_path == Pathname.new(source).parent
|
||||||
return false if page_dir == File.dirname(page_dir)
|
|
||||||
page_dir == config['source'] ||
|
|
||||||
page_dir == paginate_path ||
|
page_dir == paginate_path ||
|
||||||
in_hierarchy(config, File.dirname(page_dir))
|
in_hierarchy(source, page_dir, File.dirname(paginate_path))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Static: Return the pagination path of the page
|
# Static: Return the pagination path of the page
|
||||||
|
|
Loading…
Reference in New Issue