jekyll-plugin-gkarchive 0.2.0 → 0.3.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
  SHA256:
3
- metadata.gz: 3fabe6d66a3aa4ef37ee551014aa6edc49713fd93ece62745f61ddce8f8a3e6e
4
- data.tar.gz: 31092eefb88d0278b1c0a84b9b19415fd12eb607a71ea9d121c7843caa6e14ea
3
+ metadata.gz: 6e851c901f4153d8048540ef2f01414939e6028f4a4f6383d3633bccb43cb183
4
+ data.tar.gz: 14d57bb3565a154d271906730dd75c719ce04098c8877ceb1f7554d8b494712c
5
5
  SHA512:
6
- metadata.gz: fcb1781333e47e81b8f1f2dc77f9780297fb8196548329c4d758fe6adfe9510eb141e522ba2369d4c8970aefd5e7c3c8f40a3b1efcd0a4a9cd376196aa1bee6c
7
- data.tar.gz: fc1582a998541d4e4d035e1f16675de5bfc4587036cef375d245172214751a7ebf067c1768c6119093ea5784ca72f853be3521dc3bde73db67dd11bee8fbb744
6
+ metadata.gz: abd63284b1ed9df21f324f587a9c4d8fefb95f89aaf57fa6c320ce4898d270222e901a0feffefc3b9af1ede66e098542493b630736bcc80c29be6b734063f5ca
7
+ data.tar.gz: 89c24461be6410b0dcb1ff4fef6c23b46f03c71341075d06deeda4a0f0cb62a729db83cbbfa6911a45c89810f50b077d38ee76e99284f49e61b40acf20f058d4
@@ -1,6 +1,6 @@
1
1
  module Jekyll
2
2
  module Archive
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
6
6
 
@@ -6,6 +6,15 @@
6
6
  #
7
7
  # Download: https://github.com/jekyll/jekyll-archives
8
8
  #
9
+ # Sample Config
10
+ # jekyll-archives:
11
+ # layout: hc-archive
12
+ # category:
13
+ # - account-settings
14
+ # - deployment
15
+ # permalinks:
16
+ # category: '/hc-category/:name/'
17
+ #
9
18
  # See the documentation for full configuration and usage instructions.
10
19
  # frozen_string_literal: true
11
20
 
@@ -14,20 +23,16 @@ require "jekyll"
14
23
  module Jekyll
15
24
  module Archives
16
25
  # Internal requires
17
- autoload :Archive, "jekyll-plugin-gkarchive/archive"
18
- autoload :VERSION, "jekyll-plugin-gkarchive/version"
26
+ # autoload :Archive, "jekyll-archives/archive"
27
+ # autoload :VERSION, "jekyll-plugin-gkarchive/version"
19
28
 
20
29
  class Archives < Jekyll::Generator
21
30
  safe true
22
31
 
23
32
  DEFAULTS = {
24
33
  "layout" => "archive",
25
- "enabled" => [],
34
+ "categories" => [],
26
35
  "permalinks" => {
27
- "year" => "/:year/",
28
- "month" => "/:year/:month/",
29
- "day" => "/:year/:month/:day/",
30
- "tag" => "/tag/:name/",
31
36
  "category" => "/category/:name/",
32
37
  },
33
38
  }.freeze
@@ -38,94 +43,33 @@ module Jekyll
38
43
 
39
44
  def generate(site)
40
45
  @site = site
41
- @posts = site.collection.docs
42
- @archives = []
46
+ #@posts = site.posts
47
+ site.collections.each do |coll_name, coll_data|
48
+ if( !coll_data.nil? && coll_name == 'articles')
49
+ @posts = coll_data
50
+ end
51
+ end
43
52
 
53
+ @archives = []
44
54
  @site.config["jekyll-archives"] = @config
45
55
 
46
- read
56
+ read_categories
47
57
  @site.pages.concat(@archives)
48
58
 
49
59
  @site.config["archives"] = @archives
50
60
  end
51
61
 
52
- # Read archive data from posts
53
- def read
54
- read_tags
55
- read_categories
56
- read_dates
57
- end
58
-
59
- def read_tags
60
- if enabled? "tags"
61
- tags.each do |title, posts|
62
- @archives << Archive.new(@site, title, "tag", posts)
63
- end
64
- end
65
- end
66
62
 
67
63
  def read_categories
68
- if enabled? "categories"
69
- categories.each do |title, posts|
70
- @archives << Archive.new(@site, title, "category", posts)
71
- end
72
- end
73
- end
74
64
 
75
- def read_dates
76
- years.each do |year, posts|
77
- @archives << Archive.new(@site, { :year => year }, "year", posts) if enabled? "year"
78
- months(posts).each do |month, posts|
79
- @archives << Archive.new(@site, { :year => year, :month => month }, "month", posts) if enabled? "month"
80
- days(posts).each do |day, posts|
81
- @archives << Archive.new(@site, { :year => year, :month => month, :day => day }, "day", posts) if enabled? "day"
82
- end
83
- end
84
- end
85
- end
86
-
87
- # Checks if archive type is enabled in config
88
- def enabled?(archive)
89
- @config["enabled"] == true || @config["enabled"] == "all" || if @config["enabled"].is_a? Array
90
- @config["enabled"].include? archive
91
- end
92
- end
93
-
94
- def tags
95
- @site.post_attr_hash("tags")
96
- end
97
-
98
- def categories
99
- @site.post_attr_hash("categories")
100
- end
101
-
102
- # Custom `post_attr_hash` method for years
103
- def years
104
- hash = Hash.new { |h, key| h[key] = [] }
105
-
106
- # In Jekyll 3, Collection#each should be called on the #docs array directly.
107
- if Jekyll::VERSION >= "3.0.0"
108
- @posts.docs.each { |p| hash[p.date.strftime("%Y")] << p }
109
- else
110
- @posts.each { |p| hash[p.date.strftime("%Y")] << p }
65
+ posts = []
66
+ @posts.docs.each do |key, value|
67
+ posts << key
111
68
  end
112
- hash.each_value { |posts| posts.sort!.reverse! }
113
- hash
114
- end
69
+ @config["category"].each { |cat| @archives << Archive.new(@site, cat, "category", posts) }
115
70
 
116
- def months(year_posts)
117
- hash = Hash.new { |h, key| h[key] = [] }
118
- year_posts.each { |p| hash[p.date.strftime("%m")] << p }
119
- hash.each_value { |posts| posts.sort!.reverse! }
120
- hash
121
71
  end
122
72
 
123
- def days(month_posts)
124
- hash = Hash.new { |h, key| h[key] = [] }
125
- month_posts.each { |p| hash[p.date.strftime("%d")] << p }
126
- hash.each_value { |posts| posts.sort!.reverse! }
127
- hash
128
- end
129
73
  end
130
74
  end
131
75
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-plugin-gkarchive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - "@glueckkanja"