jekyll-paginate-v2 1.5.2 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bf3d484abb23816a1d7b0ddff858bfe8bd9910b0
4
- data.tar.gz: 38b5e268d53c4e8e5b3a02d5c46ed68178758f41
3
+ metadata.gz: 6b75b40bc9621e073c323002f7b5236f156df3ab
4
+ data.tar.gz: c535c29e9a67a5b433b3561596460662165f93ce
5
5
  SHA512:
6
- metadata.gz: 0c954800a9aec9157258a7bc2b9f19055d8066c9db7d043b670e1a51dfc9e32f8558bfcb7e782350775334096c14031efa8618cfa38d0b62ddd6be62c939919d
7
- data.tar.gz: 8041aa50ed32b79c0ae9ecb8f87a2ad86b30dbf25793bd9af0cbff3155233603bb753e0f4f2aada8c6b8f0db51afe5fb45d3937cff75c94392b514243c639f4f
6
+ metadata.gz: 2c7feec702d44b7a6e109a05c2a080700d4311fe780bce8b10145a5736c7f5b6d4af4742ed6e17adf726ccdd09bffc144882825ef95da831cd1c76ffcde7ca23
7
+ data.tar.gz: 176402fc295ac5fae913ba28e729016b7282156e0bb20eb14a2382680b4f2d2d8de9c13a757164cf250f27540f0b3ab054d79faea83ebef4ae75d79a63edbcea
@@ -1,5 +1,17 @@
1
1
  # Contributor Covenant Code of Conduct
2
2
 
3
+ > “Be kind,
4
+ >
5
+ > for everyone you meet is fighting a harder battle.”
6
+ >
7
+ > --Plato
8
+
9
+
10
+ ## TL;DR
11
+ Try to be the best version of yourself and to be excellent to others.
12
+
13
+ :purple_heart:
14
+
3
15
  ## Our Pledge
4
16
 
5
17
  In the interest of fostering an open and welcoming environment, we as
@@ -0,0 +1,84 @@
1
+ # Jekyll::Paginate V2::AutoPages
2
+
3
+ **AutoPages** are an optional pagination addon that can automatically generate paginated pages for all your collections, tags and categories used in the pages on your site. This is useful if you have a large site where paginating the contents of your collections, tags or category lists provides a better user experience.
4
+
5
+ <p align="center">
6
+ <img src="https://raw.githubusercontent.com/sverrirs/jekyll-paginate-v2/master/res/autopages-logo.png" height="128" />
7
+ </p>
8
+
9
+
10
+ > This feature is based on [code](https://github.com/stevecrozz/lithostech.com/blob/master/_plugins/tag_indexes.rb) written and graciously donated by [Stephen Crosby](https://github.com/stevecrozz). Thanks! :)
11
+
12
+ * [Site configuration](#site-configuration)
13
+ * [Advanced configuration](#advanced-configuration)
14
+ * [Specialised pages](#specialised-pages)
15
+ * [Considerations](#considerations)
16
+ * [Example Sites](https://github.com/sverrirs/jekyll-paginate-v2/tree/master/examples)
17
+ * [Common issues](#common-issues)
18
+
19
+ :warning: Please note, this feature is still **experimental** and might not be ready for production yet.
20
+
21
+ ## Site configuration
22
+
23
+ ``` yml
24
+ ############################################################
25
+ # Site configuration for the Auto-Pages feature
26
+ # The values here represent the defaults if nothing is set
27
+ autopages:
28
+
29
+ # Site-wide kill switch, disable here and it doesn't run at all
30
+ enabled: false
31
+
32
+ # Category pages, omit entire config element to disable
33
+ categories:
34
+ # Optional, the list of layouts that should be processed for every category found in the site
35
+ layouts:
36
+ - 'autopage_category.html'
37
+ # Optional, the title that each category paginate page should get (:cat is replaced by the Category name)
38
+ title: 'Posts in category :cat'
39
+ # Optional, the permalink for the pagination page (:cat is replaced),
40
+ # the pagination permalink path is then appended to this permalink structure
41
+ permalink: '/category/:cat'
42
+
43
+ # Collection pages, omit to disable
44
+ collections:
45
+ layouts:
46
+ - 'autopage_collection.html'
47
+ title: 'Posts in collection :coll' # :coll is replaced by the collection name
48
+ permalink: '/collection/:coll'
49
+
50
+ # Tag pages, omit to disable
51
+ tags:
52
+ layouts:
53
+ - 'autopage_tags.html'
54
+ title: 'Posts tagged with :tag' # :tag is replaced by the tag name
55
+ permalink: '/tag/:tag'
56
+ ```
57
+
58
+ ## Simple configuration
59
+ The only thing needed to enable the auto pages is to add the configuration element to the site.config file and then create a layout that the pages should use.
60
+
61
+ Example of a simple autopage layout can be seen in Example 3 [examples/03-tags/_layouts/autopage_tags.html](https://github.com/sverrirs/jekyll-paginate-v2/blob/master/examples/03-tags/_layouts/autopage_tags.html).
62
+
63
+ The layout does not need anything special beyond the normal pagination logic (e.g. `for post in paginator.posts` and then the next/prev arrows). You can either name the layouts by the default names (see site configuration section above) or give them a custom name and add them to the `layouts:` configuration for the relevant type of autopage.
64
+
65
+ ## Advanced configuration
66
+ You can customize the look an feel of the permalink structure and the title for the auto-pages. You can also add front-matter `pagination` configuration to the layout pages you're using to specify things like sorting, filtering and all the other configuration options that are available in the normal pagination generator.
67
+
68
+ > Keep in mind that when the autopages are paginated the pagination permalink structure and pagination title suffix is appended to them.
69
+
70
+ ## Specialised pages
71
+
72
+ Special autopages can be used that leverage the powerful filtering and sorting features of the pagination logic. For example you might want to create special pages autopages that paginate all tags in a certain collection or certain tags within a category.
73
+
74
+ To achieve this you specify the `pagination` front-matter configuration in the autopage layout file.
75
+
76
+ An example of this can be found in [examples/03-tags/_layouts/autopage_collections_tags.html](https://github.com/sverrirs/jekyll-paginate-v2/blob/master/examples/03-tags/_layouts/autopage_collections_tags.html). This page creates paginated pages for all tags that are found in the special _all_ collections.
77
+
78
+ ## Considerations
79
+
80
+ ### Title should not contain pagination macros
81
+ There is no need to include the pagination title macros `:num`, `:max` or `:title` in the title configuration. The autopages will use the title configuration from the pagination configuration itself.
82
+
83
+ ## Common issues
84
+ _None reported so far_
@@ -0,0 +1,441 @@
1
+ # Jekyll::Paginate V2::Generator
2
+
3
+ The **Generator** forms the core of the pagination logic. It is responsible for reading the posts and collections in your site and split them correctly across multiple pages according to the supplied configuration. It also performs the necessary functions to link to the previous and next pages in the page-sets that it generates.
4
+ <p align="center">
5
+ <img src="https://raw.githubusercontent.com/sverrirs/jekyll-paginate-v2/master/res/generator-logo.png" height="128" />
6
+ </p>
7
+
8
+ > The code was based on the original design of [jekyll-paginate](https://github.com/jekyll/jekyll-paginate) and features were sourced from discussions such as [#27](https://github.com/jekyll/jekyll-paginate/issues/27) (thanks [Günter Kits](https://github.com/gynter)).
9
+
10
+ * [Site configuration](#site-configuration)
11
+ * [Page configuration](#page-configuration)
12
+ * [Backwards compatibility](#backwards-compatibility-with-jekyll-paginate)
13
+ * [Example Sites](https://github.com/sverrirs/jekyll-paginate-v2/tree/master/examples)
14
+ * [Paginating collections](#paginating-collections)
15
+ + [Single collection](#paginating-a-single-collection)
16
+ + [Multiple collection](#paginating-multiple-collections)
17
+ + [The special 'all' collection](#the-special-all-collection)
18
+ * [How to paginate categories, tags, locales](#paginate-categories-tags-locales)
19
+ + [Filtering categories](#filtering-categories)
20
+ + [Filtering tags](#filtering-tags)
21
+ + [Filtering locales](#filtering-locales)
22
+ * [How to paginate on combination of filters](#paginate-on-combination-of-filters)
23
+ * [Overriding site configuration](#configuration-overrides)
24
+ * [Advanced Sorting](#advanced-sorting)
25
+ * [How to detect auto-generated pages](#detecting-generated-pagination-pages)
26
+ * [Formatting page titles](#formatting-page-titles)
27
+ * [Common issues](#common-issues)
28
+ - [Dependency Error after installing](#i-keep-getting-a-dependency-error-when-running-jekyll-serve-after-installing-this-gem)
29
+ - [Bundler error upgrading gem (Bundler::GemNotFound)](#im-getting-a-bundler-error-after-upgrading-the-gem-bundlergemnotfound)
30
+ - [Bundler error running gem (Gem::LoadError)](#im-getting-a-bundler-error-after-upgrading-the-gem-gemloaderror)
31
+ - [Pagination pages are not found](#my-pagination-pages-are-not-being-found-couldnt-find-any-pagination-page-skipping-pagination)
32
+ - [Categories cause excess folder nesting](#my-pages-are-being-nested-multiple-levels-deep)
33
+ - [Pagination pages overwriting each others pages](#my-pagination-pages-are-overwriting-each-others-pages)
34
+
35
+ ## Site configuration
36
+
37
+ The pagination gem is configured in the site's `_config.yml` file by including the `pagination` configuration element
38
+
39
+ ``` yml
40
+ ############################################################
41
+ # Site configuration for the Jekyll 3 Pagination Gem
42
+ # The values here represent the defaults if nothing is set
43
+ pagination:
44
+
45
+ # Site-wide kill switch, disabled here it doesn't run at all
46
+ enabled: true
47
+
48
+ # Set to 'true' to enable pagination debugging. This can be enabled in the site config or only for individual pagination pages
49
+ debug: false
50
+
51
+ # The default document collection to paginate if nothing is specified ('posts' is default)
52
+ collection: 'posts'
53
+
54
+ # How many objects per paginated page, used to be `paginate` (default: 0, means all)
55
+ per_page: 10
56
+
57
+ # The permalink structure for the paginated pages (this can be any level deep)
58
+ permalink: '/page/:num/'
59
+
60
+ # Optional the title format for the paginated pages (supports :title for original page title, :num for pagination page number, :max for total number of pages)
61
+ title: ':title - page :num'
62
+
63
+ # Limit how many pagenated pages to create (default: 0, means all)
64
+ limit: 0
65
+
66
+ # Optional, defines the field that the posts should be sorted on (omit to default to 'date')
67
+ sort_field: 'date'
68
+
69
+ # Optional, sorts the posts in reverse order (omit to default decending or sort_reverse: true)
70
+ sort_reverse: true
71
+
72
+ # Optional, the default category to use, omit or just leave this as 'posts' to get a backwards-compatible behavior (all posts)
73
+ category: 'posts'
74
+
75
+ # Optional, the default tag to use, omit to disable
76
+ tag: ''
77
+
78
+ # Optional, the default locale to use, omit to disable (depends on a field 'locale' to be specified in the posts,
79
+ # in reality this can be any value, suggested are the Microsoft locale-codes (e.g. en_US, en_GB) or simply the ISO-639 language code )
80
+ locale: ''
81
+
82
+ ############################################################
83
+ ```
84
+
85
+ Also ensure that you remove the old 'jekyll-paginate' gem from your `gems` list and add this new gem instead
86
+
87
+ ``` yml
88
+ gems: [jekyll-paginate-v2]
89
+ ```
90
+
91
+ ## Page configuration
92
+
93
+ To enable pagination on a page then simply include the minimal pagination configuration in the page front-matter:
94
+
95
+ ``` yml
96
+ ---
97
+ layout: page
98
+ pagination:
99
+ enabled: true
100
+ ---
101
+ ```
102
+
103
+ Then you can use the normal `paginator.posts` logic to iterate through the posts.
104
+
105
+ ``` html
106
+ {% for post in paginator.posts %}
107
+ <h1>{{ post.title }}</h1>
108
+ {% endfor %}
109
+ ```
110
+
111
+ And to display pagination links, simply
112
+
113
+ ``` html
114
+ {% if paginator.total_pages > 1 %}
115
+ <ul>
116
+ {% if paginator.previous_page %}
117
+ <li>
118
+ <a href="{{ paginator.previous_page_path | prepend: site.baseurl }}">Newer</a>
119
+ </li>
120
+ {% endif %}
121
+ {% if paginator.next_page %}
122
+ <li>
123
+ <a href="{{ paginator.next_page_path | prepend: site.baseurl }}">Older</a>
124
+ </li>
125
+ {% endif %}
126
+ </ul>
127
+ {% endif %}
128
+ ```
129
+
130
+ > All posts that have the `hidden: true` in their front matter are ignored by the pagination logic.
131
+
132
+ The code is fully backwards compatible and you will have access to all the normal paginator variables defined in the [official jekyll documentation](https://jekyllrb.com/docs/pagination/#liquid-attributes-available).
133
+
134
+ Neat! :ok_hand:
135
+
136
+ Don't delay, go see the [Examples](https://github.com/sverrirs/jekyll-paginate-v2/tree/master/examples), they're way more useful than read-me docs at this point :)
137
+
138
+ ## Backwards compatibility with jekyll-paginate
139
+ This gem is fully backwards compatible with the old [jekyll-paginate](https://github.com/jekyll/jekyll-paginate) gem and can be used as a zero-configuration replacement for it. If the old site config is detected then the gem will fall back to the old logic of pagination.
140
+
141
+ > You cannot run both the new pagination logic and the old one at the same time
142
+
143
+ The following `_config.yml` settings are honored when running this gem in compatability mode
144
+
145
+ ``` yml
146
+ paginate: 8
147
+ paginate_path: "/legacy/page:num/"
148
+ ```
149
+
150
+ See more about the old style of pagination at the [jekyll-paginate](https://github.com/jekyll/jekyll-paginate) page.
151
+
152
+ > :bangbang: **Warning** Backwards compatibility with the old jekyll-paginate gem is currently scheduled to be removed after **1st January 2018**. Users will start receiving warning log messages when running jekyll two months before this date.
153
+
154
+ ## Paginating collections
155
+ By default the pagination system only paginates `posts`. If you only have `posts` and `pages` in your site you don't need to worry about a thing, everything will work as intended without you configuring anything.
156
+
157
+ However if you use document collections, or would like to, then this pagination gem offers extensive support for paginating documents in one or more collections at the same time.
158
+
159
+ > Collections are groups of documents that belong together but should not be grouped by date.
160
+ > See more about ['collections'](http://ben.balter.com/2015/02/20/jekyll-collections/) on Ben Balters blog.
161
+
162
+ ### Paginating a single collection
163
+
164
+ Lets expand on Ben's collection discussion (linked above). Let's say that you have hundreds of cupcake pages in your cupcake collection. To create a pagination page for only documents from the cupcake collection you would do this
165
+
166
+ ``` yml
167
+ ---
168
+ layout: page
169
+ title: All Cupcakes
170
+ pagination:
171
+ enabled: true
172
+ collection: cupcakes
173
+ ---
174
+ ```
175
+
176
+ ### Paginating multiple collections
177
+
178
+ Lets say that you want to create a single pagination page for only small cakes on your page (you have both cupcakes and cookies to sell). You could do that like this
179
+
180
+ ``` yml
181
+ ---
182
+ layout: page
183
+ title: Lil'bits
184
+ pagination:
185
+ enabled: true
186
+ collection: cupcakes, cookies
187
+ ---
188
+ ```
189
+
190
+ ### The special 'all' collection
191
+
192
+ Now your site has grown and you have multiple cake collections on it and you want to have a single page that paginates all of your collections at the same time.
193
+ You can use the special `all` collection name for this.
194
+
195
+ ``` yml
196
+ ---
197
+ layout: page
198
+ title: All the Cakes!
199
+ pagination:
200
+ enabled: true
201
+ collection: all
202
+ ---
203
+ ```
204
+
205
+ > Note: Due to the `all` keyword being reserved for this feature, you cannot have a collection called `all` in your site configuration. Sorry.
206
+
207
+
208
+ ## Paginate categories, tags, locales
209
+
210
+ Enabling pagination for specific categories, tags or locales is as simple as adding values to the pagination page front-matter and corresponding values in the posts.
211
+
212
+ ### Filtering categories
213
+
214
+ Filter single category 'software'
215
+
216
+ ``` yml
217
+ ---
218
+ layout: post
219
+ pagination:
220
+ enabled: true
221
+ category: software
222
+ ---
223
+ ```
224
+
225
+ Filter multiple categories (lists only posts belonging to all categories)
226
+
227
+ ``` yml
228
+ pagination:
229
+ enabled: true
230
+ category: software, ruby
231
+ ```
232
+
233
+ > To define categories you can either specify them in the front-matter or through the [directory structure](http://jekyllrb.com/docs/variables/#page-variables) of your jekyll site (Categories are derived from the directory structure above the \_posts directory). You can actually use both approaches to assign your pages to multiple categories.
234
+
235
+ ### Filtering tags
236
+
237
+ Filter on a single tag
238
+
239
+ ``` yml
240
+ pagination:
241
+ enabled: true
242
+ tag: cool
243
+ ```
244
+
245
+ Filter on multiple tags
246
+
247
+ ``` yml
248
+ pagination:
249
+ enabled: true
250
+ tag: cool, life
251
+ ```
252
+
253
+ > When specifying tags in your posts make sure that the values are not enclosed in single quotes (double quotes are fine). If they are you will get a cryptic error when generating your site that looks like _"Error: could not read file <FILE>: did not find expected key while parsing a block mapping at line 2 column 1"_
254
+
255
+ ### Filtering locales
256
+
257
+ In the case your site offers multiple languages you can include a `locale` item in your post front matter. The paginator can then use this value to filter on
258
+
259
+ The category page front-matter would look like this
260
+
261
+ ``` yml
262
+ pagination:
263
+ enabled: true
264
+ locale: en_US
265
+ ```
266
+
267
+ Then for the relevant posts, include the `locale` variable in their front-matter
268
+
269
+ ``` yml
270
+ locale: en_US
271
+ ```
272
+
273
+ ## Paginate on combination of filters
274
+
275
+ Including only posts from categories 'ruby' and 'software' written in English
276
+
277
+ ``` yml
278
+ pagination:
279
+ enabled: true
280
+ category: software, ruby
281
+ locale: en_US, en_GB, en_WW
282
+ ```
283
+
284
+ Only showing posts tagged with 'cool' and in category 'cars'
285
+
286
+ ``` yml
287
+ pagination:
288
+ enabled: true
289
+ category: cars
290
+ tag: cool
291
+ ```
292
+
293
+ ... and so on and so on
294
+
295
+ ## Configuration overrides
296
+
297
+ All of the configuration elements from the `_config.yml` file can be overwritten in the pagination pages. E.g. if you want one category page to have different permalink structure simply override the item like so
298
+
299
+ ``` yml
300
+ pagination:
301
+ enabled: true
302
+ category: cars
303
+ permalink: '/cars/:num/'
304
+ ```
305
+
306
+ Overriding sorting to sort by the post title in ascending order for another paginated page could be done like so
307
+
308
+ ``` yml
309
+ pagination:
310
+ enabled: true
311
+ category: ruby
312
+ sort_field: 'title'
313
+ sort_reverse: false
314
+ ```
315
+
316
+ ## Advanced Sorting
317
+ Sorting can be done by any field that is available in the post front-matter. You can even sort by nested fields.
318
+
319
+ > When sorting by nested fields separate the fields with a colon `:` character.
320
+
321
+ As an example, assuming all your posts have the following front-matter
322
+
323
+ ``` yml
324
+ ---
325
+ layout: post
326
+ author:
327
+ name:
328
+ first: "John"
329
+ last: "Smith"
330
+ born: 1960
331
+ ---
332
+ ```
333
+
334
+ You can define pagination sorting on the nested `first` field like so
335
+
336
+ ``` yml
337
+ ---
338
+ layout: page
339
+ title: "Authors by first name"
340
+ pagination:
341
+ enabled: true
342
+ sort_field: 'author:name:first'
343
+ ---
344
+ ```
345
+
346
+ To sort by the `born` year in decending order (youngest first)
347
+
348
+ ``` yml
349
+ ---
350
+ layout: page
351
+ title: "Authors by birth year"
352
+ pagination:
353
+ enabled: true
354
+ sort_field: 'author:born'
355
+ sort_reverse: true
356
+ ---
357
+ ```
358
+
359
+ ## Detecting generated pagination pages
360
+
361
+ To identify the auto-generated pages that are created by the pagination logic when iterating through collections such as `site.pages` the `page.autogen` variable can be used like so
362
+
363
+ ```
364
+ {% for my_page in site.pages %}
365
+ {% if my_page.title and my_page.autogen == nil %}
366
+ <h1>{{ my_page.title | escape }}</h1>
367
+ {% endif %}
368
+ {% endfor %}
369
+ ```
370
+ _In this example only pages that have a title and are not auto-generated are included._
371
+
372
+ This variable is created and assigned the value `page.autogen = "jekyll-paginate-v2"` by the pagination logic. This way you can detect which pages are auto-generated and by what gem.
373
+
374
+ ## Formatting page titles
375
+
376
+ The `title` field in both the site.config and the front-matter configuration supports the following macros.
377
+
378
+ | Text | Replaced with | Example |
379
+ | --- | --- | --- |
380
+ | :title | original page title | Page with `title: "Index"` and paginate config `title: ":title - split"` becomes `<title>Index - split</title>` |
381
+ | :num | number of the current page | Page with `title: "Index"` and paginate config `title: ":title (page :num)"` the second page becomes `<title>Index (page 2)</title>` |
382
+ | :max | total number of pages | Page with paginate config `title: ":num of :max"` the third page of 10 will become `<title>3 of 10</title>"` |
383
+
384
+ ## Common issues
385
+
386
+ ### I keep getting a dependency error when running jekyll serve after installing this gem
387
+
388
+ > Dependency Error: Yikes! It looks like you don't have jekyll-paginate-v2 or one of its dependencies installed...
389
+
390
+ Check your `Gemfile` in the site root. Ensure that the jekyll-paginate-v2 gem is present in the jekyll_plugins group like the example below. If this group is missing add to the file.
391
+
392
+ ``` ruby
393
+ group :jekyll_plugins do
394
+ gem "jekyll-paginate-v2"
395
+ end
396
+ ```
397
+
398
+ ### I'm getting a bundler error after upgrading the gem (Bundler::GemNotFound)
399
+
400
+ > bundler/spec_set.rb:95:in `block in materialize': Could not find jekyll-paginate-v2-1.0.0 in any of the sources (Bundler::GemNotFound)
401
+
402
+ Delete your `Gemfile.lock` file and try again.
403
+
404
+
405
+ ### I'm getting a bundler error after upgrading the gem (Gem::LoadError)
406
+
407
+ > bundler/runtime.rb:40:in 'block in setup': You have already activated addressable 2.5.0, but your Gemfile requires addressable 2.4.0. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)
408
+
409
+ Delete your `Gemfile.lock` file and try again.
410
+
411
+ ### My pagination pages are not being found (Couldn't find any pagination page. Skipping pagination)
412
+
413
+ > Pagination: Is enabled, but I couldn't find any pagination page. Skipping pagination...
414
+
415
+ * Ensure that you have the correct minimum front-matter in the pagination pages
416
+ ``` yml
417
+ pagination:
418
+ enabled: true
419
+ ```
420
+ * You can place pagination logic into either the pages or liquid templates (templates are stored under the `_layouts/` and `_includes/` folders).
421
+
422
+ ### My pages are being nested multiple levels deep
423
+
424
+ When using `categories` for posts it is advisable to explicitly state a `permalink` structure in your `_config.yml` file.
425
+
426
+ ```
427
+ permalink: /:year/:month/:title.html
428
+ ```
429
+
430
+ This is because the default behavior in Jekyll is to nest pages for every category that they belong to and Jekyll unfortunately does not understand multi-categories separated with `,` or `;` but instead does all separation on `[space]` only.
431
+
432
+ ### My pagination pages are overwriting each others pages
433
+ If you specify multiple pages that paginate in the site root then you must give them unique and separate pagination permalink. This link is set in the pagination page front-matter like so
434
+
435
+ ``` yml
436
+ pagination:
437
+ enabled: true
438
+ permalink: '/cars/:num/'
439
+ ```
440
+
441
+ Make absolutely sure that your pagination permalink paths do not clash with any other paths in your final site. For simplicity it is recommended that you keep all custom pagination (non root index.html) in a single or multiple separate sub folders under your site root.