jekyll-index-pages 0.5.2 → 0.5.3

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
- SHA1:
3
- metadata.gz: f1229998c1d43a580d8b502d6e80d309b753e9cf
4
- data.tar.gz: e8da9dee48aa8484a28e91b9c6aad773117715d6
2
+ SHA256:
3
+ metadata.gz: 5ee67fae3519b7680684e5c412bfc19d5bac6a44a122494310713035ac345455
4
+ data.tar.gz: 9efd20c3b37187e8ffbd1d5d7881e8fb1820af56eba8f1c30d1532a5e41ff691
5
5
  SHA512:
6
- metadata.gz: 3fa256f6a0eff606f548a28b24a42bcdeaa583721d130dfb85ec31e80b67328b8c581a717e30255d6dab80ca5df7126de23324bb29164a77f0861b53fbf812c3
7
- data.tar.gz: 43fb7b088bcca51ece6699fdeb9f310693e8ac33232abaab808a8a9dbbca817d184fed1458c3bf8f429069ca1385e157a18e16f9c9d5e9c9b1110575cf7d7cab
6
+ metadata.gz: 82455545f0573679cc8d8cff8549bc849dfca7d7476fc5cb31217dac4252ba35419897d550a5b1f2f107a8d85ae222331a92945290afc04dc80f5427a3551cfd
7
+ data.tar.gz: f7211b3e0e467a205cf5414185f8b1f7f7258b51e3c920f41625994114a8b88ba65c7d62ab0a88cd02150ad3e781ab61191ea742f01beddd1853f10005b5beb5
@@ -3,22 +3,16 @@ module JekyllIndexPages
3
3
  priority :high
4
4
 
5
5
  def generate(site)
6
+ collections = Hash.new { |hash, key| hash[key] = [] }
6
7
  config = site.config["index_pages"] || {}
7
8
  config.each do |kind, item|
8
- case kind
9
- when "posts", "categories", "tags", "archive", "authors"
10
- next
11
- end
9
+ next if kind.match(/posts|categories|tags|archive|authors/)
12
10
  next if !item.has_key?("collection")
13
-
14
11
  coll_name = item["collection"]
15
- collections = Hash.new { |hash, key| hash[key] = [] }
16
- _, collection = site.collections.detect do |key, value|
17
- key == coll_name
18
- end
12
+ collection = site.collections[coll_name]
19
13
  collection.docs.each { |doc| collections[coll_name] << doc }
20
- site.data["collectionz"] = collections
21
14
  end
15
+ site.data["collectionz"] = collections if config.length > 0
22
16
  end
23
17
  end
24
18
  end
@@ -25,7 +25,7 @@ module JekyllIndexPages
25
25
  when "authors"
26
26
  site.data["authors"]
27
27
  else
28
- site.data["collectionz"] if collection
28
+ { collection => site.data["collectionz"][collection] } if collection
29
29
  end
30
30
 
31
31
  doc_group.each do |label, docs|
@@ -1,3 +1,3 @@
1
1
  module JekyllIndexPages
2
- VERSION = "0.5.2"
2
+ VERSION = "0.5.3"
3
3
  end
@@ -44,4 +44,34 @@ describe JekyllIndexPages::Collection do
44
44
  end
45
45
  end
46
46
  end
47
+
48
+ context "When two collections are provided in the configuration" do
49
+ let(:overrides) do
50
+ {
51
+ "collections" => ["starships", "cast"],
52
+ "index_pages" => {
53
+ "starship" => {
54
+ "collection" => "starships"
55
+ },
56
+ "cast" => {
57
+ "collection" => "cast"
58
+ }
59
+ }
60
+ }
61
+ end
62
+
63
+ describe "Collection.generate" do
64
+ it "generates an index page for each collection" do
65
+ expect(site.data["collectionz"].length).to eq(2)
66
+ end
67
+
68
+ it "the first having four documents" do
69
+ expect(site.data["collectionz"]["starships"].length).to eq(4)
70
+ end
71
+
72
+ it "the second having two documents" do
73
+ expect(site.data["collectionz"]["cast"].length).to eq(2)
74
+ end
75
+ end
76
+ end
47
77
  end
@@ -0,0 +1,5 @@
1
+ ---
2
+ title: Kate Mulgrew
3
+ series: "Star Trek: Voyager"
4
+ as: Captain Kathryn Janeway
5
+ ---
@@ -0,0 +1,5 @@
1
+ ---
2
+ title: Scott Bakula
3
+ series: "Star Trek: Enterprise"
4
+ as: Jonathan Archer
5
+ ---
@@ -323,7 +323,7 @@ describe JekyllIndexPages::Generator do
323
323
  end
324
324
  end
325
325
 
326
- context "When custom 'per page' setting for posts index page is provided" do
326
+ context "When custom 'per page' setting for collection index pages is provided" do
327
327
  let(:overrides) do
328
328
  {
329
329
  "collections" => ["starships"],
@@ -338,7 +338,7 @@ describe JekyllIndexPages::Generator do
338
338
  end
339
339
 
340
340
  describe "Generator.generate" do
341
- context "generates the first collection index page" do
341
+ context "generates the first index page for collection" do
342
342
  let(:page) { site.pages[0] }
343
343
 
344
344
  it "with two documents" do
@@ -359,7 +359,7 @@ describe JekyllIndexPages::Generator do
359
359
  end
360
360
  end
361
361
 
362
- context "generates the second collection index page" do
362
+ context "generates the second index page for collection" do
363
363
  let(:page) { site.pages[1] }
364
364
 
365
365
  it "with two documents" do
@@ -381,4 +381,52 @@ describe JekyllIndexPages::Generator do
381
381
  end
382
382
  end
383
383
  end
384
+
385
+ context "When two collections are provided in the configuration" do
386
+ let(:overrides) do
387
+ {
388
+ "collections" => ["starships", "cast"],
389
+ "index_pages" => {
390
+ "starship" => {
391
+ "layout" => "custom-layout",
392
+ "collection" => "starships"
393
+ },
394
+ "cast" => {
395
+ "layout" => "custom-layout",
396
+ "collection" => "cast"
397
+ }
398
+ }
399
+ }
400
+ end
401
+
402
+ describe "Generator.generate" do
403
+ it "generates an index page for each collection" do
404
+ expect(site.pages.length).to eq(2)
405
+ end
406
+
407
+ context "generates the index page for the first collection" do
408
+ let(:page) { site.pages[0] }
409
+
410
+ it "at /starships/" do
411
+ expect(page.url).to eq("/starships/")
412
+ end
413
+
414
+ it "and having four documents" do
415
+ expect(page.data["pager"]["docs"].length).to eq(4)
416
+ end
417
+ end
418
+
419
+ context "generates the index page for the second collection" do
420
+ let(:page) { site.pages[1] }
421
+
422
+ it "at /cast/" do
423
+ expect(page.url).to eq("/cast/")
424
+ end
425
+
426
+ it "and having two documents" do
427
+ expect(page.data["pager"]["docs"].length).to eq(2)
428
+ end
429
+ end
430
+ end
431
+ end
384
432
  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.5.2
4
+ version: 0.5.3
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: 2017-10-18 00:00:00.000000000 Z
11
+ date: 2018-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -119,6 +119,8 @@ files:
119
119
  - spec/author_spec.rb
120
120
  - spec/category-url_spec.rb
121
121
  - spec/collection_spec.rb
122
+ - spec/fixtures/index-page/_cast/kate-mulgrew.md
123
+ - spec/fixtures/index-page/_cast/scott-bakula.md
122
124
  - spec/fixtures/index-page/_config.yml
123
125
  - spec/fixtures/index-page/_layouts/archive.html
124
126
  - spec/fixtures/index-page/_layouts/authors.html
@@ -163,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
165
  version: '0'
164
166
  requirements: []
165
167
  rubyforge_project:
166
- rubygems_version: 2.6.13
168
+ rubygems_version: 2.7.7
167
169
  signing_key:
168
170
  specification_version: 4
169
171
  summary: Index page generator for Jekyll sites.
@@ -174,6 +176,8 @@ test_files:
174
176
  - spec/author_spec.rb
175
177
  - spec/category-url_spec.rb
176
178
  - spec/collection_spec.rb
179
+ - spec/fixtures/index-page/_cast/kate-mulgrew.md
180
+ - spec/fixtures/index-page/_cast/scott-bakula.md
177
181
  - spec/fixtures/index-page/_config.yml
178
182
  - spec/fixtures/index-page/_layouts/archive.html
179
183
  - spec/fixtures/index-page/_layouts/authors.html