sutty-archives 2.3.0 → 2.4.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
  SHA256:
3
- metadata.gz: 3fef8ed446f2c81a26428e355f7b4c14923fdd56b9367db006f13464f909cac8
4
- data.tar.gz: a2a0af5d85a97a779b0ca73f2300612ea333d2c2d99accd12bdc822673ba0874
3
+ metadata.gz: 4cc14da399823bcacdb254eb2a61dc1da3ef87787da6e7873ac2a119d2ce9eb1
4
+ data.tar.gz: c36acd59da6ec7e2cf8ed837c4989371e3c6edf2a4b65a087ea211f3df59f4e6
5
5
  SHA512:
6
- metadata.gz: 4933c5145a31350e62411b303ecba29f8b49a50e63baf4412ef02f6bb96f65cc82ac31febf86c459303ead1d1c7ccdcf1ce2586d323b03c53d26c7be2cdc42ab
7
- data.tar.gz: 811cf946c59dbd7c297cfe201843f76f87e043a2d964434ae4e380dbb190eec710ee040526ef270d584aafb4df6a1956dd1d392593831d67f5c9a8957f4f1856
6
+ metadata.gz: 0b8c2af7c4ba9b48932bccda9cc8bb47a560ed1d3c4d573d487a5444c26052fcb8340014ed766bdec9c2802627d5b2afd4c2a3472ec0b87a245e17a1be06cadd
7
+ data.tar.gz: 51caab8fb1756dd2f77c752c36d2fe70ed14ce863932ac6a953c1ec26edaa0d862dca7d310aa7749fea198ed2e5319f0d9f4abd3c5a2019f76bc3a0aa123a485
@@ -18,6 +18,7 @@ module Jekyll
18
18
 
19
19
  DEFAULTS = {
20
20
  "layout" => "archive",
21
+ "group" => false,
21
22
  "enabled" => [],
22
23
  "titles" => {},
23
24
  "replace" => false,
@@ -56,14 +57,15 @@ module Jekyll
56
57
  read
57
58
  @site.pages.concat(@archives)
58
59
 
59
- @site.config["archives"] = @archives
60
+ @site.config["archives"] = @archives unless group?
60
61
  end
61
62
 
62
63
  # Read archive data from posts
63
64
  def read
64
65
  read_attrs
65
- read_categories_tags
66
+ read_categories_tags if enabled? "categories-tags"
66
67
  read_dates
68
+ read_types if group?
67
69
  end
68
70
 
69
71
  # Read and group by attributes, using the legacy names when
@@ -76,6 +78,11 @@ module Jekyll
76
78
  next unless attr_title_enabled? attr, title
77
79
 
78
80
  @archives << Archive.new(@site, title, attr, posts)
81
+
82
+ next unless group?
83
+
84
+ @site.config['archives'] ||= {}
85
+ @site.config['archives'][attr] = @archives.last
79
86
  end
80
87
  end
81
88
  end
@@ -93,16 +100,14 @@ module Jekyll
93
100
  end
94
101
 
95
102
  def read_categories_tags
96
- if enabled? "categories-tags"
97
- @site.categories.each do |category, posts|
98
- posts.map { |post| post.data['tags'] }.flatten.uniq.compact.each do |tag|
99
- category_tag_posts = posts.select do |post|
100
- post.data['categories'].include?(category) &&
101
- post.data['tags'].include?(tag)
102
- end
103
-
104
- @archives << Archive.new(@site, { category: category, tag: tag }, "category-tag", category_tag_posts)
103
+ @site.categories.each do |category, posts|
104
+ posts.map { |post| post.data['tags'] }.flatten.uniq.compact.each do |tag|
105
+ category_tag_posts = posts.select do |post|
106
+ post.data['categories'].include?(category) &&
107
+ post.data['tags'].include?(tag)
105
108
  end
109
+
110
+ @archives << Archive.new(@site, { category: category, tag: tag }, "category-tag", category_tag_posts)
106
111
  end
107
112
  end
108
113
  end
@@ -119,6 +124,15 @@ module Jekyll
119
124
  end
120
125
  end
121
126
 
127
+ # Generates Archives by Archive type
128
+ def read_types
129
+ @config['enabled'].each do |type|
130
+ type = LEGACY_ATTRS[type] if LEGACY_ATTRS[type]
131
+
132
+ @archives << Archive.new(@site, type, 'type', @archives[type].posts)
133
+ end
134
+ end
135
+
122
136
  # Return the front matter attributes to archive by, using the
123
137
  # legacy names unless specified and leaving out the date
124
138
  # attributes.
@@ -133,6 +147,11 @@ module Jekyll
133
147
  @enabled == true || @enabled == "all" || (@enabled.is_a?(Array) && @enabled.include?(archive))
134
148
  end
135
149
 
150
+ # Checks if we want grouped archives
151
+ def group?
152
+ @config['group']
153
+ end
154
+
136
155
  # Custom `post_attr_hash` method for years
137
156
  def years
138
157
  date_attr_hash(@posts.docs, "%Y")
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  module Archives
5
- VERSION = "2.3.0"
5
+ VERSION = "2.4.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sutty-archives
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alfred Xing
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-09-29 00:00:00.000000000 Z
12
+ date: 2020-10-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jekyll