octopress-paginate 1.0.0 → 1.1.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
  SHA1:
3
- metadata.gz: acab0386b92350ad9e120e5b4412dd80a53b4d36
4
- data.tar.gz: a26a9217a701686b3fc3d4d9927a92c91e84774f
3
+ metadata.gz: cdb9b591fdc9f11af9fc2cb3a20baef96d83db36
4
+ data.tar.gz: dad38d9bfc07d065a2ebe20dc1aff8bffb46e256
5
5
  SHA512:
6
- metadata.gz: f835d5f0918a183738991b0b74be51f6e3ab57121557a8a70f3d4d0f0e30d9b8579d795da357460966f2c8e860a080a6e68c71ef75bb6b25dd5d589074297e43
7
- data.tar.gz: fc3ace64ead955a8eba2b362d84cea5e36f24dd4d0afc1166a8bb2764b2cd9954cfc9f69d472ceac22687706d9eadad65c8b1b6f7614687f4e48fbb09e370508
6
+ metadata.gz: ee890b2580f06e6e9d370d7414e350ebfe6290040989f6addf786e6837abb37a00f3dd64e07b09e62331756b781b9bf07497ceba4ab65ddaed60f0c7ea063c1d
7
+ data.tar.gz: 95b88ea34100c6dfac058b34a4e9520c55223028e47073c5191345eaa8f97c12b6e72aa12fcc124fcb03f20db9a6fdc129f4851ebbb49dc98e0424726fcae208
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ### 1.1.0 (2015-02-11)
4
+
5
+ - New: Configure site-wide defaults in _config.yml
6
+
3
7
  ### 1.0.0 (2015-02-10)
4
8
 
5
9
  - Initial release
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
- In a page's YAML front-matter, setting `paginate: true` turns that page into a template for pagination. To configure pagination,
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 posts per page
95
- limit: 5 # Maximum number of pages to paginate (0 for unlimited)
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 posts in this category
99
- categories: [] # Paginate posts in any of these categories
100
- tag: '' # Paginate posts tagged with this tag
101
- tags: [] # Paginate posts tagged with any of these tags
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
@@ -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'] = DEFAULT.merge(page.data['paginate'])
26
+ page.data['paginate'] = defaults.merge(page.data['paginate'])
24
27
  else
25
- page.data['paginate'] = DEFAULT
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'] > 0
46
+ if config['limit']
44
47
  pages = [pages, config['limit'] - 1].min
45
48
  end
46
49
 
@@ -1,5 +1,5 @@
1
1
  module Octopress
2
2
  module Paginate
3
- VERSION = "1.0.0"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octopress-paginate
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Mathis