jekyll-index-pages 0.6.0 → 0.7.0

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: 15b1bb8d47b230b04e9f5494826715b53e9d45667c91b39181f4e0f95f38e621
4
- data.tar.gz: 940618a6e09b35ddc2cf16a99cad645e1189678e615f084ffd8808757c67f9f8
3
+ metadata.gz: cb7c18d211338644857081590675369c4a95f25bf868ec1d3d9a826c45e2fa86
4
+ data.tar.gz: 7fc7d7a8189af324659467dd05217fcfd830091b3abd43532ef006a46884c8a4
5
5
  SHA512:
6
- metadata.gz: 01705f933b4716cbc199e6d685fb2f4f31c9e6980d26f6ff3d6ce7e8054e16b4d01bc3fdba60edca999f7dbd51612116f67c097d9fb8b7f587de46f1f2a0e070
7
- data.tar.gz: b24eb1a4defef28a49c2cd4577b031a682fbf66b92344020b3267fc0e9f4eea0483249bdbed362f517ec39870d46338e9545903fbd9e59f84b05a7f1d5f1c189
6
+ metadata.gz: 36145d8c4629ce4a8e92cdbc003a3bc13af9e90dd60a3502a82d5596eac60800779a4eb67907a3aca4bc7ff7692917df4dc7a78c19a0a34c71311925ffb4785c
7
+ data.tar.gz: 95074d86fbbebec59d495a4415e39e37500a68295fc79c3144798ca269b6f9e35bc2dfc5a1fb99532a80d4efb815199f69e9b6416b42f281640f925e8fe97055
data/README.md CHANGED
@@ -99,19 +99,11 @@ title: :label
99
99
  excerpt: :label
100
100
  per_page: 10
101
101
  permalink: /:label/
102
- layout: posts|categories|tags|authors|archive
103
102
  ```
104
103
 
105
104
  For categories and tags, `:label` variable refers to the category or tag name. For posts, `:label` will always be equal to `posts`. For the archive, `:label` refers to any given year. For authors, `:label` is the author name. `:label` value is slugified when composing the permalink.
106
105
 
107
- Default value for layout depends on the type of index page. For collection index pages, the default layout is the same as the custon name used to define the collection config:
108
-
109
- ```yaml
110
- custom_name:
111
- layout: custom_name
112
- collection: collection_name
113
- ...
114
- ```
106
+ > Note there is no default value for layout. You must always specify this setting otherwise pages will be generated blank, with no markup.
115
107
 
116
108
  Because this plugin [transliterates](http://stackoverflow.com/a/20586777) the URL for generated pages, you need to define a language as follows:
117
109
 
@@ -48,15 +48,8 @@ module JekyllIndexPages
48
48
  (pager.current_page > 1) ? pager.current_page.to_s : ""
49
49
  )
50
50
 
51
- base =
52
- if site.in_theme_dir()
53
- site.in_theme_dir()
54
- else
55
- site.in_source_dir()
56
- end
57
-
58
51
  site.pages <<
59
- IndexPage.new(site, base, dir, item, label, layout, pager)
52
+ IndexPage.new(site, site.source, dir, item, label, pager)
60
53
  end
61
54
  end
62
55
  end
@@ -1,26 +1,18 @@
1
1
  module JekyllIndexPages
2
2
  class IndexPage < Jekyll::Page
3
- def initialize(site, base, dir, config, label, layout, pager)
3
+ def initialize(site, base, dir, config, label, pager)
4
4
  @site = site
5
5
  @base = base
6
6
  @dir = dir
7
- @name = "index.html"
8
-
9
- layout_dir = "_layouts"
10
- layout_name = "#{layout}.html"
11
-
12
- @path =
13
- if site.in_theme_dir(base) == base
14
- site.in_theme_dir(base, layout_dir, layout_name)
15
- else
16
- site.in_source_dir(base, layout_dir, layout_name)
17
- end
7
+ @name = "index.md"
18
8
 
19
9
  title = config["title"] || ":label"
20
10
  excerpt = config["excerpt"] || ":label"
21
11
 
22
12
  self.process(@name)
23
- self.read_yaml(File.join(base, layout_dir), layout_name)
13
+
14
+ self.content = ""
15
+ self.data = {}
24
16
 
25
17
  if config.key?("data") and config["data"].is_a?(Hash)
26
18
  config["data"].each do |key, value|
@@ -29,6 +21,7 @@ module JekyllIndexPages
29
21
  end
30
22
 
31
23
  self.data["title"] = title.sub(":label", label)
24
+ self.data["layout"] = config["layout"]
32
25
  self.data["excerpt"] = excerpt.sub(":label", label)
33
26
 
34
27
  self.data["pager"] = Hash.new
@@ -51,6 +44,8 @@ module JekyllIndexPages
51
44
  else
52
45
  ""
53
46
  end
47
+
48
+ Jekyll::Hooks.trigger :pages, :post_init, self
54
49
  end
55
50
  end
56
51
  end
@@ -1,3 +1,3 @@
1
1
  module JekyllIndexPages
2
- VERSION = "0.6.0"
2
+ VERSION = "0.7.0"
3
3
  end
@@ -0,0 +1,12 @@
1
+ ---
2
+ ---
3
+ <html>
4
+ <head>
5
+ <title>{{ page.title }}</title>
6
+ <meta name="description" content="{{ page.excerpt | strip_html }}">
7
+ </head>
8
+ <body>
9
+ <p>{{ page.custom }}</p>
10
+ {{ content }}
11
+ </body>
12
+ </html>
@@ -0,0 +1,12 @@
1
+ ---
2
+ ---
3
+ <html>
4
+ <head>
5
+ <title>{{ page.title }}</title>
6
+ <meta name="description" content="{{ page.excerpt | strip_html }}">
7
+ </head>
8
+ <body>
9
+ <p>This is a liquid layout</p>
10
+ {{ content }}
11
+ </body>
12
+ </html>
@@ -178,7 +178,7 @@ describe JekyllIndexPages::Generator do
178
178
  end
179
179
  end
180
180
 
181
- context "When custom 'layout' setting for posts index page is provided" do
181
+ context "When a custom layout is provided in posts index page configuration" do
182
182
  let(:overrides) do
183
183
  {
184
184
  "index_pages" => {
@@ -192,7 +192,26 @@ describe JekyllIndexPages::Generator do
192
192
  describe "Generator.generate" do
193
193
  it "generates a post index page using the custom layout" do
194
194
  expect(site.pages.length).to eq(1)
195
- expect(site.pages[0].content).to include("Custom Layout")
195
+ expect(site.pages[0].output).to include("Custom Layout")
196
+ end
197
+ end
198
+ end
199
+
200
+ context "When a liquid file is provided as a layout in posts index page configuration" do
201
+ let(:overrides) do
202
+ {
203
+ "index_pages" => {
204
+ "posts" => {
205
+ "layout" => "liquid-layout"
206
+ }
207
+ }
208
+ }
209
+ end
210
+
211
+ describe "Generator.generate" do
212
+ it "generates a post index page using the liquid layout" do
213
+ expect(site.pages.length).to eq(1)
214
+ expect(site.pages[0].output).to include("This is a liquid layout")
196
215
  end
197
216
  end
198
217
  end
@@ -202,6 +221,7 @@ describe JekyllIndexPages::Generator do
202
221
  {
203
222
  "index_pages" => {
204
223
  "posts" => {
224
+ "layout" => "data-layout",
205
225
  "data" => {
206
226
  "custom" => "This is a custom data item"
207
227
  }
@@ -214,7 +234,7 @@ describe JekyllIndexPages::Generator do
214
234
  it "generates an index page containing the custom data items" do
215
235
  expect(site.pages.length).to eq(1)
216
236
  expect(site.pages[0].data["custom"]).to eq("This is a custom data item")
217
- expect(site.pages[0].content).to include("This is a custom data item")
237
+ expect(site.pages[0].output).to include("This is a custom data item")
218
238
  end
219
239
  end
220
240
  end
@@ -11,7 +11,6 @@ describe JekyllIndexPages::IndexPage do
11
11
  let(:base) { site.source }
12
12
  let(:dir) { "/posts/" }
13
13
  let(:label) { "posts" }
14
- let(:layout) { "default" }
15
14
  let(:pagination) do
16
15
  JekyllIndexPages::Pagination.new(site.posts.docs.reverse, 2)
17
16
  end
@@ -23,7 +22,6 @@ describe JekyllIndexPages::IndexPage do
23
22
  dir,
24
23
  config,
25
24
  label,
26
- layout,
27
25
  pager
28
26
  )
29
27
  end
@@ -48,7 +46,11 @@ describe JekyllIndexPages::IndexPage do
48
46
  end
49
47
 
50
48
  it "with no additional data" do
51
- expect(page.data.length).to eq(3)
49
+ expect(page.data.length).to eq(4)
50
+ expect(page.data.keys).to include("title")
51
+ expect(page.data.keys).to include("layout")
52
+ expect(page.data.keys).to include("excerpt")
53
+ expect(page.data.keys).to include("pager")
52
54
  end
53
55
 
54
56
  it "listing the first two posts" do
@@ -127,7 +129,11 @@ describe JekyllIndexPages::IndexPage do
127
129
 
128
130
  describe "IndexPage.initialize" do
129
131
  it "will not add any custom data to index page" do
130
- expect(page.data.length).to eq(3)
132
+ expect(page.data.length).to eq(4)
133
+ expect(page.data.keys).to include("title")
134
+ expect(page.data.keys).to include("layout")
135
+ expect(page.data.keys).to include("excerpt")
136
+ expect(page.data.keys).to include("pager")
131
137
  end
132
138
  end
133
139
  end
@@ -136,9 +142,11 @@ describe JekyllIndexPages::IndexPage do
136
142
  let(:config) do
137
143
  {
138
144
  "title" => "Star Trek Index",
145
+ "layout" => "default",
139
146
  "excerpt" => "Star Trek Index",
140
147
  "data" => {
141
148
  "title" => "This is another title",
149
+ "layout" => nil,
142
150
  "excerpt" => "This is another excerpt",
143
151
  "pager" => nil
144
152
  }
@@ -148,6 +156,7 @@ describe JekyllIndexPages::IndexPage do
148
156
  describe "IndexPage.initialize" do
149
157
  it "will preserve the original data" do
150
158
  expect(page.data["title"]).to eq("Star Trek Index")
159
+ expect(page.data["layout"]).to eq("default")
151
160
  expect(page.data["excerpt"]).to eq("Star Trek Index")
152
161
  expect(page.data["pager"]).to be_instance_of(Hash)
153
162
  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.6.0
4
+ version: 0.7.0
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-02 00:00:00.000000000 Z
11
+ date: 2018-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -126,7 +126,9 @@ files:
126
126
  - spec/fixtures/index-page/_layouts/authors.html
127
127
  - spec/fixtures/index-page/_layouts/categories.html
128
128
  - spec/fixtures/index-page/_layouts/custom-layout.html
129
+ - spec/fixtures/index-page/_layouts/data-layout.html
129
130
  - spec/fixtures/index-page/_layouts/default.html
131
+ - spec/fixtures/index-page/_layouts/liquid-layout.liquid
130
132
  - spec/fixtures/index-page/_layouts/posts.html
131
133
  - spec/fixtures/index-page/_layouts/tags.html
132
134
  - spec/fixtures/index-page/_locales/en-US.yml
@@ -183,7 +185,9 @@ test_files:
183
185
  - spec/fixtures/index-page/_layouts/authors.html
184
186
  - spec/fixtures/index-page/_layouts/categories.html
185
187
  - spec/fixtures/index-page/_layouts/custom-layout.html
188
+ - spec/fixtures/index-page/_layouts/data-layout.html
186
189
  - spec/fixtures/index-page/_layouts/default.html
190
+ - spec/fixtures/index-page/_layouts/liquid-layout.liquid
187
191
  - spec/fixtures/index-page/_layouts/posts.html
188
192
  - spec/fixtures/index-page/_layouts/tags.html
189
193
  - spec/fixtures/index-page/_locales/en-US.yml