Feature for the pagination templating
This commit is contained in:
parent
937efcf8b8
commit
5bbdf2239d
|
@ -21,3 +21,20 @@ Feature: Site pagination
|
||||||
| num |
|
| num |
|
||||||
| 1 |
|
| 1 |
|
||||||
| 2 |
|
| 2 |
|
||||||
|
|
||||||
|
Scenario: Correct liquid paginator replacements
|
||||||
|
Given I have a configuration file with "paginate" set to "1"
|
||||||
|
And I have a _layouts directory
|
||||||
|
And I have an "index.html" file that contains "{{ paginator.page }}"
|
||||||
|
And I have a _posts directory
|
||||||
|
And I have the following post:
|
||||||
|
| title | date | layout | content |
|
||||||
|
| Wargames | 3/27/2009 | default | The only winning move is not to play. |
|
||||||
|
| Wargames2 | 4/27/2009 | default | The only winning move is not to play2. |
|
||||||
|
When I run jekyll
|
||||||
|
Then the _site/index.html file should exist
|
||||||
|
And I should see "1" in "_site/index.html"
|
||||||
|
Then the _site/page2 directory should exist
|
||||||
|
And the _site/page2/index.html file should exist
|
||||||
|
And I should see "2" in "_site/page2/index.html"
|
||||||
|
|
|
@ -250,11 +250,9 @@ module Jekyll
|
||||||
# "next_page" => <Number> }}
|
# "next_page" => <Number> }}
|
||||||
def paginate_posts(file, dir)
|
def paginate_posts(file, dir)
|
||||||
all_posts = self.posts.sort { |a,b| b <=> a }
|
all_posts = self.posts.sort { |a,b| b <=> a }
|
||||||
|
|
||||||
pages = Pager.calculate_pages(all_posts, self.config['paginate'].to_i)
|
pages = Pager.calculate_pages(all_posts, self.config['paginate'].to_i)
|
||||||
pages += 1
|
pages += 1
|
||||||
(1..pages).each do |num_page|
|
(1..pages).each do |num_page|
|
||||||
|
|
||||||
pager = Pager.new(self.config, num_page, all_posts, pages)
|
pager = Pager.new(self.config, num_page, all_posts, pages)
|
||||||
page = Page.new(self, self.source, dir, file)
|
page = Page.new(self, self.source, dir, file)
|
||||||
page.render(self.layouts, site_payload.merge({'paginator' => pager.to_hash}))
|
page.render(self.layouts, site_payload.merge({'paginator' => pager.to_hash}))
|
||||||
|
|
Loading…
Reference in New Issue