jekyll-paginate-v2-redux 1.7.6

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.
Files changed (32) hide show
  1. checksums.yaml +7 -0
  2. data/CODE_OF_CONDUCT.md +86 -0
  3. data/Gemfile +8 -0
  4. data/LICENSE +22 -0
  5. data/README-AUTOPAGES.md +104 -0
  6. data/README-GENERATOR.md +520 -0
  7. data/README.md +77 -0
  8. data/Rakefile +16 -0
  9. data/jekyll-paginate-v2-redux.gemspec +32 -0
  10. data/lib/jekyll-paginate-v2-redux.rb +34 -0
  11. data/lib/jekyll-paginate-v2-redux/autopages/autoPages.rb +77 -0
  12. data/lib/jekyll-paginate-v2-redux/autopages/defaults.rb +29 -0
  13. data/lib/jekyll-paginate-v2-redux/autopages/pages/baseAutoPage.rb +60 -0
  14. data/lib/jekyll-paginate-v2-redux/autopages/pages/categoryAutoPage.rb +28 -0
  15. data/lib/jekyll-paginate-v2-redux/autopages/pages/collectionAutoPage.rb +28 -0
  16. data/lib/jekyll-paginate-v2-redux/autopages/pages/tagAutoPage.rb +28 -0
  17. data/lib/jekyll-paginate-v2-redux/autopages/utils.rb +74 -0
  18. data/lib/jekyll-paginate-v2-redux/generator/compatibilityUtils.rb +121 -0
  19. data/lib/jekyll-paginate-v2-redux/generator/defaults.rb +24 -0
  20. data/lib/jekyll-paginate-v2-redux/generator/paginationGenerator.rb +141 -0
  21. data/lib/jekyll-paginate-v2-redux/generator/paginationIndexer.rb +93 -0
  22. data/lib/jekyll-paginate-v2-redux/generator/paginationModel.rb +358 -0
  23. data/lib/jekyll-paginate-v2-redux/generator/paginationPage.rb +50 -0
  24. data/lib/jekyll-paginate-v2-redux/generator/paginator.rb +84 -0
  25. data/lib/jekyll-paginate-v2-redux/generator/utils.rb +109 -0
  26. data/lib/jekyll-paginate-v2-redux/version.rb +10 -0
  27. data/spec/generator/defaults_spec.rb +34 -0
  28. data/spec/generator/paginationPage_spec.rb +12 -0
  29. data/spec/generator/paginator_spec.rb +107 -0
  30. data/spec/generator/utils_spec.rb +67 -0
  31. data/spec/spec_helper.rb +13 -0
  32. metadata +139 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e053ece4702c033c8888d81987ed5e29cf10f659
4
+ data.tar.gz: 52a83630ba8d3de3630c57058d673ce2674ef901
5
+ SHA512:
6
+ metadata.gz: 9e63dd021fa294df25a9321c72c861de8e286d9bdb01c4ce2f88675af134049cceaafbca950ac42a57f47e9aca178d9c4bb2d88606b46f62ec9a5822fd7f3936
7
+ data.tar.gz: 2cb740ca3629ed4b8f9b9b9d4fb5c5310d447eb0a4889c6fc2f5a3941d9d932009855507fc41d42ffac1974da755b2edd8f2c953a1ce16b64c8b0aa7735d13e8
@@ -0,0 +1,86 @@
1
+ # Contributor Covenant Code of Conduct
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
+
15
+ ## Our Pledge
16
+
17
+ In the interest of fostering an open and welcoming environment, we as
18
+ contributors and maintainers pledge to making participation in our project and
19
+ our community a harassment-free experience for everyone, regardless of age, body
20
+ size, disability, ethnicity, gender identity and expression, level of experience,
21
+ nationality, personal appearance, race, religion, or sexual identity and
22
+ orientation.
23
+
24
+ ## Our Standards
25
+
26
+ Examples of behavior that contributes to creating a positive environment
27
+ include:
28
+
29
+ * Using welcoming and inclusive language
30
+ * Being respectful of differing viewpoints and experiences
31
+ * Gracefully accepting constructive criticism
32
+ * Focusing on what is best for the community
33
+ * Showing empathy towards other community members
34
+
35
+ Examples of unacceptable behavior by participants include:
36
+
37
+ * The use of sexualized language or imagery and unwelcome sexual attention or
38
+ advances
39
+ * Trolling, insulting/derogatory comments, and personal or political attacks
40
+ * Public or private harassment
41
+ * Publishing others' private information, such as a physical or electronic
42
+ address, without explicit permission
43
+ * Other conduct which could reasonably be considered inappropriate in a
44
+ professional setting
45
+
46
+ ## Our Responsibilities
47
+
48
+ Project maintainers are responsible for clarifying the standards of acceptable
49
+ behavior and are expected to take appropriate and fair corrective action in
50
+ response to any instances of unacceptable behavior.
51
+
52
+ Project maintainers have the right and responsibility to remove, edit, or
53
+ reject comments, commits, code, wiki edits, issues, and other contributions
54
+ that are not aligned to this Code of Conduct, or to ban temporarily or
55
+ permanently any contributor for other behaviors that they deem inappropriate,
56
+ threatening, offensive, or harmful.
57
+
58
+ ## Scope
59
+
60
+ This Code of Conduct applies both within project spaces and in public spaces
61
+ when an individual is representing the project or its community. Examples of
62
+ representing a project or community include using an official project e-mail
63
+ address, posting via an official social media account, or acting as an appointed
64
+ representative at an online or offline event. Representation of a project may be
65
+ further defined and clarified by project maintainers.
66
+
67
+ ## Enforcement
68
+
69
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
70
+ reported by contacting the project team at [jekyll@sverrirs.com](mailto:jekyll@sverrirs.com). All
71
+ complaints will be reviewed and investigated and will result in a response that
72
+ is deemed necessary and appropriate to the circumstances. The project team is
73
+ obligated to maintain confidentiality with regard to the reporter of an incident.
74
+ Further details of specific enforcement policies may be posted separately.
75
+
76
+ Project maintainers who do not follow or enforce the Code of Conduct in good
77
+ faith may face temporary or permanent repercussions as determined by other
78
+ members of the project's leadership.
79
+
80
+ ## Attribution
81
+
82
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
83
+ available at [http://contributor-covenant.org/version/1/4][version]
84
+
85
+ [homepage]: http://contributor-covenant.org
86
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jekyll-paginate-v2.gemspec
4
+ gemspec
5
+
6
+ if ENV["JEKYLL_VERSION"]
7
+ gem "jekyll", "~> #{ENV["JEKYLL_VERSION"]}"
8
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Sverrir Sigmundarson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,104 @@
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
+ * [Simple configuration](#simple-configuration)
14
+ + [Obtaining the original Tag or Category name](#obtaining-the-original-tag-or-category-name)
15
+ * [Advanced configuration](#advanced-configuration)
16
+ * [Specialised pages](#specialised-pages)
17
+ * [Considerations](#considerations)
18
+ + [Title should not contain pagination macros](#title-should-not-contain-pagination-macros)
19
+ * [Example Sites](https://github.com/sverrirs/jekyll-paginate-v2/tree/master/examples)
20
+ * [Common issues](#common-issues)
21
+
22
+ :warning: Please note, this feature is still **experimental** and might not be ready for production yet.
23
+
24
+ ## Site configuration
25
+
26
+ ``` yml
27
+ ############################################################
28
+ # Site configuration for the Auto-Pages feature
29
+ # The values here represent the defaults if nothing is set
30
+ autopages:
31
+
32
+ # Site-wide kill switch, disable here and it doesn't run at all
33
+ enabled: false
34
+
35
+ # Category pages, omit entire config element to disable
36
+ categories:
37
+ # Optional, the list of layouts that should be processed for every category found in the site
38
+ layouts:
39
+ - 'autopage_category.html'
40
+ # Optional, the title that each category paginate page should get (:cat is replaced by the Category name)
41
+ title: 'Posts in category :cat'
42
+ # Optional, the permalink for the pagination page (:cat is replaced),
43
+ # the pagination permalink path is then appended to this permalink structure
44
+ permalink: '/category/:cat'
45
+
46
+ # Collection pages, omit to disable
47
+ collections:
48
+ layouts:
49
+ - 'autopage_collection.html'
50
+ title: 'Posts in collection :coll' # :coll is replaced by the collection name
51
+ permalink: '/collection/:coll'
52
+
53
+ # Tag pages, omit to disable
54
+ tags:
55
+ layouts:
56
+ - 'autopage_tags.html'
57
+ title: 'Posts tagged with :tag' # :tag is replaced by the tag name
58
+ permalink: '/tag/:tag'
59
+ ```
60
+
61
+ ## Simple configuration
62
+ 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.
63
+
64
+ 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).
65
+
66
+ 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.
67
+
68
+ ### Obtaining the original Tag or Category name
69
+ Internally the autopage system will trim and downcase the indexing key (tag, category or collection name). To retrieve the original name of the index key you can use the `autopages.display_name` liquid variable.
70
+
71
+ ``` html
72
+ <h1 class="page-heading">All pages tagged with <b>{% if page.autopages %}{{page.autopages.display_name}}{% endif %}</b></h1>
73
+ ```
74
+
75
+ This variable returns the untouched key value. As an example if your site uses the tag `Science-Fiction` then
76
+
77
+ ```
78
+ page.tag = "science-fiction"
79
+ page.autopages.display_name = "Science-Fiction"
80
+ ```
81
+
82
+ See [#6](https://github.com/sverrirs/jekyll-paginate-v2/issues/6) for more information.
83
+
84
+
85
+ ## Advanced configuration
86
+ 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.
87
+
88
+ > Keep in mind that when the autopages are paginated the pagination permalink structure and pagination title suffix is appended to them.
89
+
90
+ ## Specialised pages
91
+
92
+ 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.
93
+
94
+ To achieve this you specify the `pagination` front-matter configuration in the autopage layout file.
95
+
96
+ 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.
97
+
98
+ ## Considerations
99
+
100
+ ### Title should not contain pagination macros
101
+ 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.
102
+
103
+ ## Common issues
104
+ _None reported so far_
@@ -0,0 +1,520 @@
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
+ * [Creating Pagination Trails](#creating-pagination-trails)
26
+ * [How to detect auto-generated pages](#detecting-generated-pagination-pages)
27
+ * [Formatting page titles](#formatting-page-titles)
28
+ * [Reading pagination meta information](#reading-pagination-meta-information)
29
+ * [Common issues](#common-issues)
30
+ - [Dependency Error after installing](#i-keep-getting-a-dependency-error-when-running-jekyll-serve-after-installing-this-gem)
31
+ - [Bundler error upgrading gem (Bundler::GemNotFound)](#im-getting-a-bundler-error-after-upgrading-the-gem-bundlergemnotfound)
32
+ - [Bundler error running gem (Gem::LoadError)](#im-getting-a-bundler-error-after-upgrading-the-gem-gemloaderror)
33
+ - [Pagination pages are not found](#my-pagination-pages-are-not-being-found-couldnt-find-any-pagination-page-skipping-pagination)
34
+ - [Categories cause excess folder nesting](#my-pages-are-being-nested-multiple-levels-deep)
35
+ - [Pagination pages overwriting each others pages](#my-pagination-pages-are-overwriting-each-others-pages)
36
+
37
+ ## Site configuration
38
+
39
+ The pagination gem is configured in the site's `_config.yml` file by including the `pagination` configuration element
40
+
41
+ ``` yml
42
+ ############################################################
43
+ # Site configuration for the Jekyll 3 Pagination Gem
44
+ # The values here represent the defaults if nothing is set
45
+ pagination:
46
+
47
+ # Site-wide kill switch, disabled here it doesn't run at all
48
+ enabled: true
49
+
50
+ # Set to 'true' to enable pagination debugging. This can be enabled in the site config or only for individual pagination pages
51
+ debug: false
52
+
53
+ # The default document collection to paginate if nothing is specified ('posts' is default)
54
+ collection: 'posts'
55
+
56
+ # How many objects per paginated page, used to be `paginate` (default: 0, means all)
57
+ per_page: 10
58
+
59
+ # The permalink structure for the paginated pages (this can be any level deep)
60
+ permalink: '/page/:num/' # Pages are index.html inside this folder (default)
61
+ #permalink: '/page/:num.html' # Pages are simple html files
62
+ #permalink: '/page/:num' # Pages are html files, linked jekyll extensionless permalink style.
63
+
64
+ # 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)
65
+ title: ':title - page :num'
66
+
67
+ # Limit how many pagenated pages to create (default: 0, means all)
68
+ limit: 0
69
+
70
+ # Optional, defines the field that the posts should be sorted on (omit to default to 'date')
71
+ sort_field: 'date'
72
+
73
+ # Optional, sorts the posts in reverse order (omit to default decending or sort_reverse: true)
74
+ sort_reverse: true
75
+
76
+ # Optional, the default category to use, omit or just leave this as 'posts' to get a backwards-compatible behavior (all posts)
77
+ category: 'posts'
78
+
79
+ # Optional, the default tag to use, omit to disable
80
+ tag: ''
81
+
82
+ # Optional, the default locale to use, omit to disable (depends on a field 'locale' to be specified in the posts,
83
+ # 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 )
84
+ locale: ''
85
+
86
+ # Optional,omit or set both before and after to zero to disable.
87
+ # Controls how the pagination trail for the paginated pages look like.
88
+ trail:
89
+ before: 2
90
+ after: 2
91
+
92
+ ############################################################
93
+ ```
94
+
95
+ Also ensure that you remove the old 'jekyll-paginate' gem from your `gems` list and add this new gem instead
96
+
97
+ ``` yml
98
+ gems: [jekyll-paginate-v2]
99
+ ```
100
+
101
+ ## Page configuration
102
+
103
+ To enable pagination on a page then simply include the minimal pagination configuration in the page front-matter:
104
+
105
+ ``` yml
106
+ ---
107
+ layout: page
108
+ pagination:
109
+ enabled: true
110
+ ---
111
+ ```
112
+
113
+ Then you can use the normal `paginator.posts` logic to iterate through the posts.
114
+
115
+ ``` html
116
+ {% for post in paginator.posts %}
117
+ <h1>{{ post.title }}</h1>
118
+ {% endfor %}
119
+ ```
120
+
121
+ And to display pagination links, simply
122
+
123
+ ``` html
124
+ {% if paginator.total_pages > 1 %}
125
+ <ul>
126
+ {% if paginator.previous_page %}
127
+ <li>
128
+ <a href="{{ paginator.previous_page_path | prepend: site.baseurl }}">Newer</a>
129
+ </li>
130
+ {% endif %}
131
+ {% if paginator.next_page %}
132
+ <li>
133
+ <a href="{{ paginator.next_page_path | prepend: site.baseurl }}">Older</a>
134
+ </li>
135
+ {% endif %}
136
+ </ul>
137
+ {% endif %}
138
+ ```
139
+
140
+ > All posts that have the `hidden: true` in their front matter are ignored by the pagination logic.
141
+
142
+ 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).
143
+
144
+ Neat! :ok_hand:
145
+
146
+ 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 :)
147
+
148
+ ## Backwards compatibility with jekyll-paginate
149
+ 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.
150
+
151
+ > You cannot run both the new pagination logic and the old one at the same time
152
+
153
+ The following `_config.yml` settings are honored when running this gem in compatability mode
154
+
155
+ ``` yml
156
+ paginate: 8
157
+ paginate_path: "/legacy/page:num/"
158
+ ```
159
+
160
+ See more about the old style of pagination at the [jekyll-paginate](https://github.com/jekyll/jekyll-paginate) page.
161
+
162
+ > :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.
163
+
164
+ ## Paginating collections
165
+ 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.
166
+
167
+ 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.
168
+
169
+ > Collections are groups of documents that belong together but should not be grouped by date.
170
+ > See more about ['collections'](http://ben.balter.com/2015/02/20/jekyll-collections/) on Ben Balters blog.
171
+
172
+ ### Paginating a single collection
173
+
174
+ 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
175
+
176
+ ``` yml
177
+ ---
178
+ layout: page
179
+ title: All Cupcakes
180
+ pagination:
181
+ enabled: true
182
+ collection: cupcakes
183
+ ---
184
+ ```
185
+
186
+ ### Paginating multiple collections
187
+
188
+ 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
189
+
190
+ ``` yml
191
+ ---
192
+ layout: page
193
+ title: Lil'bits
194
+ pagination:
195
+ enabled: true
196
+ collection: cupcakes, cookies
197
+ ---
198
+ ```
199
+
200
+ ### The special 'all' collection
201
+
202
+ 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.
203
+ You can use the special `all` collection name for this.
204
+
205
+ ``` yml
206
+ ---
207
+ layout: page
208
+ title: All the Cakes!
209
+ pagination:
210
+ enabled: true
211
+ collection: all
212
+ ---
213
+ ```
214
+
215
+ > Note: Due to the `all` keyword being reserved for this feature, you cannot have a collection called `all` in your site configuration. Sorry.
216
+
217
+
218
+ ## Paginate categories, tags, locales
219
+
220
+ 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.
221
+
222
+ ### Filtering categories
223
+
224
+ Filter single category 'software'
225
+
226
+ ``` yml
227
+ ---
228
+ layout: post
229
+ pagination:
230
+ enabled: true
231
+ category: software
232
+ ---
233
+ ```
234
+
235
+ Filter multiple categories (lists only posts belonging to all categories)
236
+
237
+ ``` yml
238
+ pagination:
239
+ enabled: true
240
+ category: software, ruby
241
+ ```
242
+
243
+ > 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.
244
+
245
+ ### Filtering tags
246
+
247
+ Filter on a single tag
248
+
249
+ ``` yml
250
+ pagination:
251
+ enabled: true
252
+ tag: cool
253
+ ```
254
+
255
+ Filter on multiple tags
256
+
257
+ ``` yml
258
+ pagination:
259
+ enabled: true
260
+ tag: cool, life
261
+ ```
262
+
263
+ > 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"_
264
+
265
+ ### Filtering locales
266
+
267
+ 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
268
+
269
+ The category page front-matter would look like this
270
+
271
+ ``` yml
272
+ pagination:
273
+ enabled: true
274
+ locale: en_US
275
+ ```
276
+
277
+ Then for the relevant posts, include the `locale` variable in their front-matter
278
+
279
+ ``` yml
280
+ locale: en_US
281
+ ```
282
+
283
+ ## Paginate on combination of filters
284
+
285
+ Including only posts from categories 'ruby' and 'software' written in English
286
+
287
+ ``` yml
288
+ pagination:
289
+ enabled: true
290
+ category: software, ruby
291
+ locale: en_US, en_GB, en_WW
292
+ ```
293
+
294
+ Only showing posts tagged with 'cool' and in category 'cars'
295
+
296
+ ``` yml
297
+ pagination:
298
+ enabled: true
299
+ category: cars
300
+ tag: cool
301
+ ```
302
+
303
+ ... and so on and so on
304
+
305
+ ## Configuration overrides
306
+
307
+ 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
308
+
309
+ ``` yml
310
+ pagination:
311
+ enabled: true
312
+ category: cars
313
+ permalink: '/cars/:num/'
314
+ ```
315
+
316
+ Overriding sorting to sort by the post title in ascending order for another paginated page could be done like so
317
+
318
+ ``` yml
319
+ pagination:
320
+ enabled: true
321
+ category: ruby
322
+ sort_field: 'title'
323
+ sort_reverse: false
324
+ ```
325
+
326
+ ## Advanced Sorting
327
+ Sorting can be done by any field that is available in the post front-matter. You can even sort by nested fields.
328
+
329
+ > When sorting by nested fields separate the fields with a colon `:` character.
330
+
331
+ As an example, assuming all your posts have the following front-matter
332
+
333
+ ``` yml
334
+ ---
335
+ layout: post
336
+ author:
337
+ name:
338
+ first: "John"
339
+ last: "Smith"
340
+ born: 1960
341
+ ---
342
+ ```
343
+
344
+ You can define pagination sorting on the nested `first` field like so
345
+
346
+ ``` yml
347
+ ---
348
+ layout: page
349
+ title: "Authors by first name"
350
+ pagination:
351
+ enabled: true
352
+ sort_field: 'author:name:first'
353
+ ---
354
+ ```
355
+
356
+ To sort by the `born` year in decending order (youngest first)
357
+
358
+ ``` yml
359
+ ---
360
+ layout: page
361
+ title: "Authors by birth year"
362
+ pagination:
363
+ enabled: true
364
+ sort_field: 'author:born'
365
+ sort_reverse: true
366
+ ---
367
+ ```
368
+
369
+ ## Creating Pagination Trails
370
+
371
+ <p align="center">
372
+ <img src="https://raw.githubusercontent.com/sverrirs/jekyll-paginate-v2/master/res/pagination-trails.png" />
373
+ </p>
374
+
375
+ Creating a trail structure for your pagination as shown above can be achieved by enabling the `trail` configuration and including a little extra code in your liquid templates.
376
+
377
+ ``` yml
378
+ pagination:
379
+ trail:
380
+ before: 2 # The number of links before the current page
381
+ after: 2 # The number of links after the current page
382
+ ```
383
+
384
+ Your layout file would then have to include code similar to the following to generate the correct HTML structure
385
+
386
+ ``` HTML
387
+ {% if paginator.page_trail %}
388
+ {% for trail in paginator.page_trail %}
389
+ <li {% if page.url == trail.path %}class="selected"{% endif %}>
390
+ <a href="{{ trail.path | prepend: site.baseurl }}" title="{{trail.title}}">{{ trail.num }}</a>
391
+ </li>
392
+ {% endfor %}
393
+ {% endif %}
394
+ ```
395
+ _See [example 3](https://github.com/sverrirs/jekyll-paginate-v2/tree/master/examples/03-tags) for a demo of a pagination trail_
396
+
397
+ The `trail` object exposes three properties:
398
+ * `num`: The number of the page
399
+ * `path`: The path to the page
400
+ * `title`: The title of the page
401
+
402
+ The algorithm will always attempt to keep the same trail length for all pages (`trail length = before + after + 1`).
403
+ As an example if we have only 7 pagination pages in total and the user is currently on page 6 then the trail would look like this
404
+
405
+ <p align="center">
406
+ <img src="https://raw.githubusercontent.com/sverrirs/jekyll-paginate-v2/master/res/pagination-trails-p6.png" />
407
+ </p>
408
+
409
+ Different number of before and after trail links can be specified. Below is an example of how the yml config below would look like when on the same page 4
410
+
411
+ ``` yml
412
+ pagination:
413
+ trail:
414
+ before: 1
415
+ after: 3
416
+ ```
417
+
418
+ <p align="center">
419
+ <img src="https://raw.githubusercontent.com/sverrirs/jekyll-paginate-v2/master/res/pagination-trails-p4-b1a3.png" />
420
+ </p>
421
+
422
+ ## Detecting generated pagination pages
423
+
424
+ 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
425
+
426
+ ```
427
+ {% for my_page in site.pages %}
428
+ {% if my_page.title and my_page.autogen == nil %}
429
+ <h1>{{ my_page.title | escape }}</h1>
430
+ {% endif %}
431
+ {% endfor %}
432
+ ```
433
+ _In this example only pages that have a title and are not auto-generated are included._
434
+
435
+ 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.
436
+
437
+ ## Formatting page titles
438
+
439
+ The `title` field in both the site.config and the front-matter configuration supports the following macros.
440
+
441
+ | Text | Replaced with | Example |
442
+ | --- | --- | --- |
443
+ | :title | original page title | Page with `title: "Index"` and paginate config `title: ":title - split"` becomes `<title>Index - split</title>` |
444
+ | :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>` |
445
+ | :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>"` |
446
+
447
+ ## Reading pagination meta information
448
+ Each pagination page defines an information structure `pagination_info` that is available to the liquid templates. This structure contains meta information for the pagination process, such as current pagination page and the total number of paginated pages.
449
+
450
+ The following fields are available
451
+
452
+ | Field | Description |
453
+ | --- | --- |
454
+ | curr_page | The number of the current pagination page |
455
+ | total_pages | The total number of pages in this pagination |
456
+
457
+ Below is an example on how to print out a "Page x of n" in the pagination layout
458
+
459
+ ``` html
460
+ <h2>Page {{page.pagination_info.curr_page}} of {{page.pagination_info.total_pages}}</h2>
461
+ ```
462
+
463
+ ## Common issues
464
+
465
+ ### I keep getting a dependency error when running jekyll serve after installing this gem
466
+
467
+ > Dependency Error: Yikes! It looks like you don't have jekyll-paginate-v2 or one of its dependencies installed...
468
+
469
+ 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.
470
+
471
+ ``` ruby
472
+ group :jekyll_plugins do
473
+ gem "jekyll-paginate-v2"
474
+ end
475
+ ```
476
+
477
+ ### I'm getting a bundler error after upgrading the gem (Bundler::GemNotFound)
478
+
479
+ > 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)
480
+
481
+ Delete your `Gemfile.lock` file and try again.
482
+
483
+
484
+ ### I'm getting a bundler error after upgrading the gem (Gem::LoadError)
485
+
486
+ > 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)
487
+
488
+ Delete your `Gemfile.lock` file and try again.
489
+
490
+ ### My pagination pages are not being found (Couldn't find any pagination page. Skipping pagination)
491
+
492
+ > Pagination: Is enabled, but I couldn't find any pagination page. Skipping pagination...
493
+
494
+ * Ensure that you have the correct minimum front-matter in the pagination pages
495
+ ``` yml
496
+ pagination:
497
+ enabled: true
498
+ ```
499
+ * You can place pagination logic into either the pages or liquid templates (templates are stored under the `_layouts/` and `_includes/` folders).
500
+
501
+ ### My pages are being nested multiple levels deep
502
+
503
+ When using `categories` for posts it is advisable to explicitly state a `permalink` structure in your `_config.yml` file.
504
+
505
+ ```
506
+ permalink: /:year/:month/:title.html
507
+ ```
508
+
509
+ 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.
510
+
511
+ ### My pagination pages are overwriting each others pages
512
+ 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
513
+
514
+ ``` yml
515
+ pagination:
516
+ enabled: true
517
+ permalink: '/cars/:num/'
518
+ ```
519
+
520
+ 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.