Paginate in subdirectories properly. Fixes #878.
This commit is contained in:
parent
3e670e72ab
commit
ea71036e8c
|
@ -11,7 +11,7 @@ module Jekyll
|
||||||
# Returns nothing.
|
# Returns nothing.
|
||||||
def generate(site)
|
def generate(site)
|
||||||
site.pages.dup.each do |page|
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -65,11 +65,13 @@ module Jekyll
|
||||||
# Determine if pagination is enabled for a given file.
|
# Determine if pagination is enabled for a given file.
|
||||||
#
|
#
|
||||||
# config - The configuration Hash.
|
# 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.
|
# Returns true if pagination is enabled, false otherwise.
|
||||||
def self.pagination_enabled?(config, file)
|
def self.pagination_enabled?(config, page)
|
||||||
file == 'index.html' && !config['paginate'].nil?
|
page.name == 'index.html' &&
|
||||||
|
!config['paginate'].nil? &&
|
||||||
|
File.dirname(config['paginate_path']) == page.dir
|
||||||
end
|
end
|
||||||
|
|
||||||
# Static: Return the pagination path of the page
|
# Static: Return the pagination path of the page
|
||||||
|
@ -80,7 +82,7 @@ module Jekyll
|
||||||
# Returns the pagination path as a string
|
# Returns the pagination path as a string
|
||||||
def self.paginate_path(site_config, num_page)
|
def self.paginate_path(site_config, num_page)
|
||||||
return nil if num_page.nil? || num_page <= 1
|
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)
|
format.sub(':num', num_page.to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue