jekyll-index-pages 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb7c18d211338644857081590675369c4a95f25bf868ec1d3d9a826c45e2fa86
4
- data.tar.gz: 7fc7d7a8189af324659467dd05217fcfd830091b3abd43532ef006a46884c8a4
3
+ metadata.gz: 1725fefe2150c0b61facbf34b84b655aac64458552c6b42e8e46ceea388e9fd8
4
+ data.tar.gz: 1f5805523c75303f812dc255f5bf96e96a7dd6cac6bcdfc8be85eb7b644dfe4a
5
5
  SHA512:
6
- metadata.gz: 36145d8c4629ce4a8e92cdbc003a3bc13af9e90dd60a3502a82d5596eac60800779a4eb67907a3aca4bc7ff7692917df4dc7a78c19a0a34c71311925ffb4785c
7
- data.tar.gz: 95074d86fbbebec59d495a4415e39e37500a68295fc79c3144798ca269b6f9e35bc2dfc5a1fb99532a80d4efb815199f69e9b6416b42f281640f925e8fe97055
6
+ metadata.gz: 4cd05f8dd434a92e10c7c3eb194c7b996f715f46a3ee1173ed0f56e8ad6d786512af0e2bc222371491c8d219ce1010cd3a967c0af4bf814e067208fb1de73bc4
7
+ data.tar.gz: 588c44bc859c001547405bff53f9d04e46e839c0827fb85ede3d8cc911be0cbb42e146c39c7f8c66b6fa3bf2a1ddd40f8c5dc7b66dcd3ac9dbf79442d8cd6eca
@@ -4,7 +4,8 @@ module JekyllIndexPages
4
4
 
5
5
  def generate(site)
6
6
  authors = Hash.new { |hash, key| hash[key] = [] }
7
- site.posts.docs.each { |doc| authors[doc.data["author"]] << doc }
7
+ authored_docs = site.posts.docs.select { |doc| doc.data.key?("author") }
8
+ authored_docs.each { |doc| authors[doc.data["author"]] << doc }
8
9
  site.data["authors"] = authors
9
10
  end
10
11
  end
@@ -1,3 +1,3 @@
1
1
  module JekyllIndexPages
2
- VERSION = "0.7.0"
2
+ VERSION = "0.7.1"
3
3
  end
@@ -0,0 +1,7 @@
1
+ ---
2
+ title: "Star Trek: The Next Generation"
3
+ category: Science fiction
4
+ tags: star-trek
5
+ ---
6
+
7
+ # Star Trek: The Next Generation
@@ -49,8 +49,8 @@ describe JekyllIndexPages::Generator do
49
49
  expect(site.pages[0].data["pager"]).to be_instance_of(Hash)
50
50
  end
51
51
 
52
- it "generates a post index page with six documents" do
53
- expect(site.pages[0].data["pager"]["docs"].length).to eq(6)
52
+ it "generates a post index page with seven documents" do
53
+ expect(site.pages[0].data["pager"]["docs"].length).to eq(7)
54
54
  end
55
55
 
56
56
  it "generates a post index page with recent documents first" do
@@ -67,10 +67,13 @@ describe JekyllIndexPages::Generator do
67
67
  expect(fourth.date).to eq(Time.new(1987, 9, 28))
68
68
 
69
69
  fifth = site.pages[0].data["pager"]["docs"][4]
70
- expect(fifth.date).to eq(Time.new(1966, 9, 8))
70
+ expect(fifth.date).to eq(Time.new(1987, 9, 28))
71
71
 
72
72
  sixth = site.pages[0].data["pager"]["docs"][5]
73
73
  expect(sixth.date).to eq(Time.new(1966, 9, 8))
74
+
75
+ seventh = site.pages[0].data["pager"]["docs"][6]
76
+ expect(seventh.date).to eq(Time.new(1966, 9, 8))
74
77
  end
75
78
  end
76
79
  end
@@ -152,8 +155,38 @@ describe JekyllIndexPages::Generator do
152
155
  context "generates the third post index page" do
153
156
  let(:page) { site.pages[2] }
154
157
 
155
- it "with previous page url only" do
158
+ it "with two documents" do
159
+ expect(page.data["pager"]["docs"].length).to eq(2)
160
+ end
161
+
162
+ it "sorted by date, recent first" do
163
+ first = page.data["pager"]["docs"][0]
164
+ expect(first.date).to eq(Time.new(1987, 9, 28))
165
+
166
+ second = page.data["pager"]["docs"][1]
167
+ expect(second.date).to eq(Time.new(1966, 9, 8))
168
+ end
169
+
170
+ it "with previous and next page urls" do
156
171
  expect(page.data["pager"]["prev_page_url"]).to eq("/posts/2/")
172
+ expect(page.data["pager"]["next_page_url"]).to eq("/posts/4/")
173
+ end
174
+ end
175
+
176
+ context "generates the fourth post index page" do
177
+ let(:page) { site.pages[3] }
178
+
179
+ it "with one document" do
180
+ expect(page.data["pager"]["docs"].length).to eq(1)
181
+ end
182
+
183
+ it "sorted by date, recent first" do
184
+ first = page.data["pager"]["docs"][0]
185
+ expect(first.date).to eq(Time.new(1966, 9, 8))
186
+ end
187
+
188
+ it "with previous page url only" do
189
+ expect(page.data["pager"]["prev_page_url"]).to eq("/posts/3/")
157
190
  expect(page.data["pager"]["next_page_url"]).to eq("")
158
191
  end
159
192
  end
@@ -58,7 +58,7 @@ describe JekyllIndexPages::IndexPage do
58
58
  end
59
59
 
60
60
  it "containing pagination data" do
61
- expect(page.data["pager"]["total_pages"]).to eq(3)
61
+ expect(page.data["pager"]["total_pages"]).to eq(4)
62
62
  expect(page.data["pager"]["current_page"]).to eq(1)
63
63
  expect(page.data["pager"]["prev_page"]).to eq(0)
64
64
  expect(page.data["pager"]["next_page"]).to eq(2)
@@ -92,6 +92,19 @@ describe JekyllIndexPages::IndexPage do
92
92
 
93
93
  it "containing url for prev page only" do
94
94
  expect(page.data["pager"]["prev_page_url"]).to eq("/posts/2/")
95
+ expect(page.data["pager"]["next_page_url"]).to eq("/posts/4/")
96
+ end
97
+ end
98
+
99
+ context "creates the fourth index page" do
100
+ let(:dir) { "/posts/4" }
101
+ let(:pager) do
102
+ pagination.paginate(3)
103
+ pagination.pager
104
+ end
105
+
106
+ it "containing url for prev page only" do
107
+ expect(page.data["pager"]["prev_page_url"]).to eq("/posts/3/")
95
108
  expect(page.data["pager"]["next_page_url"]).to eq("")
96
109
  end
97
110
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-index-pages
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jose Miguel Venegas Mendoza
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-04 00:00:00.000000000 Z
11
+ date: 2018-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -134,6 +134,7 @@ files:
134
134
  - spec/fixtures/index-page/_locales/en-US.yml
135
135
  - spec/fixtures/index-page/_posts/1966-09-08-star-trek-the-original-series.md
136
136
  - spec/fixtures/index-page/_posts/1966-09-08-viaje-a-las-estrellas-la-serie-original.md
137
+ - spec/fixtures/index-page/_posts/1987-09-28-star-trek-the-next-generation-no-author.md
137
138
  - spec/fixtures/index-page/_posts/1987-09-28-star-trek-the-next-generation.md
138
139
  - spec/fixtures/index-page/_posts/1993-01-03-star-trek-deep-space-nine.md
139
140
  - spec/fixtures/index-page/_posts/1995-01-16-star-trek-voyager.md
@@ -193,6 +194,7 @@ test_files:
193
194
  - spec/fixtures/index-page/_locales/en-US.yml
194
195
  - spec/fixtures/index-page/_posts/1966-09-08-star-trek-the-original-series.md
195
196
  - spec/fixtures/index-page/_posts/1966-09-08-viaje-a-las-estrellas-la-serie-original.md
197
+ - spec/fixtures/index-page/_posts/1987-09-28-star-trek-the-next-generation-no-author.md
196
198
  - spec/fixtures/index-page/_posts/1987-09-28-star-trek-the-next-generation.md
197
199
  - spec/fixtures/index-page/_posts/1993-01-03-star-trek-deep-space-nine.md
198
200
  - spec/fixtures/index-page/_posts/1995-01-16-star-trek-voyager.md