From 10c5cfc10134c7bdc20b29a71da9612f819074c2 Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Wed, 23 Dec 2015 11:45:49 -0500 Subject: [PATCH 1/2] Update pagination.rb checks if post is in 'paginate_category' directory (specified in _config.yml) --- lib/jekyll-paginate/pagination.rb | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/jekyll-paginate/pagination.rb b/lib/jekyll-paginate/pagination.rb index 87d86fb..01420e6 100644 --- a/lib/jekyll-paginate/pagination.rb +++ b/lib/jekyll-paginate/pagination.rb @@ -38,7 +38,7 @@ def generate(site) # "previous_page" => , # "next_page" => }} def paginate(site, page) - all_posts = site.site_payload['site']['posts'].reject { |post| post['hidden'] } + all_posts = site.site_payload['site']['posts'].reject { |post| post['hidden'] || !in_category(site, post) } pages = Pager.calculate_pages(all_posts, site.config['paginate'].to_i) (1..pages).each do |num_page| pager = Pager.new(site, num_page, all_posts, pages) @@ -52,7 +52,20 @@ def paginate(site, page) end end end - + + # checks if post is in 'paginate_category' directory + # + # _config.yml + # paginate_category: blog + def in_category?(site, post) + if category = site.config['paginate_category'] + path = Pathname.new(post.relative_path).parent.to_s + path.eql?("#{category}/_posts") + else + true + end + end + # Static: Fetch the URL of the template page. Used to determine the # path to the first pager in the series. # From b4c66ee1100c006de4d5176e147914f6d3873269 Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Wed, 23 Dec 2015 12:31:59 -0500 Subject: [PATCH 2/2] Update pagination.rb --- lib/jekyll-paginate/pagination.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jekyll-paginate/pagination.rb b/lib/jekyll-paginate/pagination.rb index 01420e6..e2cc018 100644 --- a/lib/jekyll-paginate/pagination.rb +++ b/lib/jekyll-paginate/pagination.rb @@ -38,7 +38,7 @@ def generate(site) # "previous_page" => , # "next_page" => }} def paginate(site, page) - all_posts = site.site_payload['site']['posts'].reject { |post| post['hidden'] || !in_category(site, post) } + all_posts = site.site_payload['site']['posts'].reject { |post| post['hidden'] || !in_category?(site, post) } pages = Pager.calculate_pages(all_posts, site.config['paginate'].to_i) (1..pages).each do |num_page| pager = Pager.new(site, num_page, all_posts, pages)