diff --git a/README.md b/README.md index 67fd2fc..684a482 100644 --- a/README.md +++ b/README.md @@ -18,10 +18,14 @@ Or install it yourself as: $ gem install jekyll-paginate -## Usage - Once the gem is installed on your system, Jekyll will auto-require it. Just set the following configuration +## Optional settings + +Paginate only one category (for home page, other use-cases). Add to `_config.yml`: + + paginate_category: "blog" + ## Contributing 1. Fork it ( http://github.com/jekyll/jekyll-paginate/fork ) diff --git a/lib/jekyll-paginate/pagination.rb b/lib/jekyll-paginate/pagination.rb index 98a3461..29f4a54 100644 --- a/lib/jekyll-paginate/pagination.rb +++ b/lib/jekyll-paginate/pagination.rb @@ -38,7 +38,12 @@ def generate(site) # "previous_page" => , # "next_page" => }} def paginate(site, page) - all_posts = site.site_payload['site']['posts'] + if site.config['paginate_category'].nil? || site.config['paginate_category'].empty? + all_posts = site.site_payload['site']['posts'] + else + selected_category = site.config['paginate_category'] + all_posts = site.site_payload['site']['categories'][selected_category] + end 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) @@ -82,4 +87,4 @@ def template_page(site) end end -end +end \ No newline at end of file