Paginate in subdirectories properly. Fixes #878.

This commit is contained in:
Parker Moore 2013-05-05 15:40:13 +02:00
parent 3e670e72ab
commit ea71036e8c
1 changed files with 7 additions and 5 deletions

View File

@ -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