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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1725fefe2150c0b61facbf34b84b655aac64458552c6b42e8e46ceea388e9fd8
|
4
|
+
data.tar.gz: 1f5805523c75303f812dc255f5bf96e96a7dd6cac6bcdfc8be85eb7b644dfe4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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
|
data/spec/generator_spec.rb
CHANGED
@@ -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
|
53
|
-
expect(site.pages[0].data["pager"]["docs"].length).to eq(
|
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(
|
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
|
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
|
data/spec/index-page_spec.rb
CHANGED
@@ -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(
|
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.
|
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-
|
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
|