octopress-paginate 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +25 -8
- data/lib/octopress-paginate.rb +6 -3
- data/lib/octopress-paginate/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cdb9b591fdc9f11af9fc2cb3a20baef96d83db36
|
4
|
+
data.tar.gz: dad38d9bfc07d065a2ebe20dc1aff8bffb46e256
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee890b2580f06e6e9d370d7414e350ebfe6290040989f6addf786e6837abb37a00f3dd64e07b09e62331756b781b9bf07497ceba4ab65ddaed60f0c7ea063c1d
|
7
|
+
data.tar.gz: 95b88ea34100c6dfac058b34a4e9520c55223028e47073c5191345eaa8f97c12b6e72aa12fcc124fcb03f20db9a6fdc129f4851ebbb49dc98e0424726fcae208
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -85,22 +85,39 @@ Just like Jekyll's paginator, your pagination pages will have access to the foll
|
|
85
85
|
|
86
86
|
## Configuration
|
87
87
|
|
88
|
-
|
89
|
-
set the options for the `paginate` key. Here are the defaults.
|
88
|
+
Pagination is configured on a per-page basis under the `paginate` key in a page's YAML front-matter. Setting `paginate: true` enables pagination with these defaults.
|
90
89
|
|
91
90
|
```yaml
|
92
91
|
paginate:
|
93
92
|
collection: posts
|
94
|
-
per_page: 10 # maximum number of
|
95
|
-
limit: 5 # Maximum number of pages to paginate (
|
93
|
+
per_page: 10 # maximum number of items per page
|
94
|
+
limit: 5 # Maximum number of pages to paginate (false for unlimited)
|
96
95
|
permalink: /page:num/ # pagination path (relative to template page)
|
97
96
|
title_suffix: " - page :num" # Append to template's page title
|
98
|
-
category: '' # Paginate
|
99
|
-
categories: [] # Paginate
|
100
|
-
tag: '' # Paginate
|
101
|
-
tags: [] # Paginate
|
97
|
+
category: '' # Paginate items in this category
|
98
|
+
categories: [] # Paginate items in any of these categories
|
99
|
+
tag: '' # Paginate items tagged with this tag
|
100
|
+
tags: [] # Paginate items tagged with any of these tags
|
102
101
|
```
|
103
102
|
|
103
|
+
Why set a pagination limit? For sites with lots of posts, this should speed up your build time considerably since Jekyll won't have to generate and write so many additional pages. Additionally, I suspect that it is very uncommon for users to browse paginated post indexes beyond a few pages. If you don't like it, it's easy to disable.
|
104
|
+
|
105
|
+
### Site-wide pagination defaults
|
106
|
+
|
107
|
+
You can set your own site-wide pagination defaults by configuring the `pagination` key in Jekyll's site config.
|
108
|
+
|
109
|
+
<!-- title:"Site wide configuration _config.yml" -->
|
110
|
+
|
111
|
+
```yaml
|
112
|
+
pagination:
|
113
|
+
limit: false
|
114
|
+
per_page: 20
|
115
|
+
title_suffix: " (page :num)"
|
116
|
+
```
|
117
|
+
|
118
|
+
Note: this will only change the defaults. A page's YAML front-matter will
|
119
|
+
override these defaults.
|
120
|
+
|
104
121
|
### Pagination permalinks
|
105
122
|
|
106
123
|
Assume your pagination template page was at `/index.html`. The second pagination page would be
|
data/lib/octopress-paginate.rb
CHANGED
@@ -19,10 +19,13 @@ module Octopress
|
|
19
19
|
LOOP = /(paginate.+\s+in)\s+(site\.(.+?))(.+)%}/
|
20
20
|
|
21
21
|
def paginate(page)
|
22
|
+
|
23
|
+
defaults = DEFAULT.merge(page.site.config['pagination'] || {})
|
24
|
+
|
22
25
|
if page.data['paginate'].is_a? Hash
|
23
|
-
page.data['paginate'] =
|
26
|
+
page.data['paginate'] = defaults.merge(page.data['paginate'])
|
24
27
|
else
|
25
|
-
page.data['paginate'] =
|
28
|
+
page.data['paginate'] = defaults
|
26
29
|
end
|
27
30
|
|
28
31
|
if tag = page.data['paginate']['tag']
|
@@ -40,7 +43,7 @@ module Octopress
|
|
40
43
|
config = page.data['paginate']
|
41
44
|
pages = (collection(page).size.to_f / config['per_page']).ceil - 1
|
42
45
|
|
43
|
-
if config['limit']
|
46
|
+
if config['limit']
|
44
47
|
pages = [pages, config['limit'] - 1].min
|
45
48
|
end
|
46
49
|
|