jekyll-archives-v2 0.0.4 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jekyll-archives-v2/archive.rb +10 -9
- data/lib/jekyll-archives-v2/version.rb +1 -1
- data/lib/jekyll-archives-v2.rb +41 -43
- metadata +22 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9e2dfffe66ba0ceefe1eb7197a1f1520e55a683e7d741a9445152535aa22c2c
|
4
|
+
data.tar.gz: ab2b84ac05c6ae09d2020059024de384b6289b0b64267f1bbb6060320ccf6fdf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52e63725865bdde06001b9b0c7c44814aa8a4486a59151800181df4ace4bfc8050a8b3175e254a781db4eb3ed3c50b0e55e3177b3f5e463bd7b0d2b47edb913a
|
7
|
+
data.tar.gz: 215a4818de5e28326aab33d6034e3ecb6a21e67600268c15633810d22cd5ef5cb1f24f2a4c012be5fe508b7640b10a475e9f454056ee2be32c207bff420c5b01
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
require 'active_support/inflector'
|
2
3
|
|
3
4
|
module Jekyll
|
4
5
|
module ArchivesV2
|
@@ -20,12 +21,12 @@ module Jekyll
|
|
20
21
|
|
21
22
|
# Initialize a new Archive page
|
22
23
|
#
|
23
|
-
# site
|
24
|
-
# title
|
25
|
-
#
|
26
|
-
# type
|
24
|
+
# site - The Site object.
|
25
|
+
# title - The name of the tag/category or a Hash of the year/month/day in case of date.
|
26
|
+
# e.g. { :year => 2014, :month => 08 } or "my-category" or "my-tag".
|
27
|
+
# type - The type of archive. Can be one of "year", "month", "day", "category", or "tag"
|
27
28
|
# collection_name - The name of the collection.
|
28
|
-
# documents
|
29
|
+
# documents - The array of documents that belong in this archive.
|
29
30
|
def initialize(site, title, type, collection_name, documents)
|
30
31
|
@site = site
|
31
32
|
@documents = documents
|
@@ -48,9 +49,9 @@ module Jekyll
|
|
48
49
|
|
49
50
|
# The template of the permalink.
|
50
51
|
#
|
51
|
-
# Returns the template String.
|
52
|
+
# Returns the template String as defined in config, else returns default template.
|
52
53
|
def template
|
53
|
-
@config.dig("permalinks", type)
|
54
|
+
@config.dig("permalinks", type) || "/:collection/:type/:name/"
|
54
55
|
end
|
55
56
|
|
56
57
|
# The layout to use for rendering
|
@@ -64,9 +65,9 @@ module Jekyll
|
|
64
65
|
# desired placeholder replacements. For details see "url.rb".
|
65
66
|
def url_placeholders
|
66
67
|
if @title.is_a? Hash
|
67
|
-
@title.merge(:collection => @collection_name, :type => @type)
|
68
|
+
@title.merge(:collection => @collection_name, :type => @type.singularize)
|
68
69
|
else
|
69
|
-
{ :collection => @collection_name, :name => @slug, :type => @type }
|
70
|
+
{ :collection => @collection_name, :name => @slug, :type => @type.singularize }
|
70
71
|
end
|
71
72
|
end
|
72
73
|
|
data/lib/jekyll-archives-v2.rb
CHANGED
@@ -19,11 +19,10 @@ module Jekyll
|
|
19
19
|
"layout" => "archive",
|
20
20
|
"enabled" => [],
|
21
21
|
"permalinks" => {
|
22
|
-
"year" => "
|
23
|
-
"month" => "
|
24
|
-
"day" => "
|
25
|
-
"
|
26
|
-
"category" => "/#{name}/category/:name/",
|
22
|
+
"year" => "/:collection/:year/",
|
23
|
+
"month" => "/:collection/:year/:month/",
|
24
|
+
"day" => "/:collection/:year/:month/:day/",
|
25
|
+
"tags" => "/:collection/:type/:name/",
|
27
26
|
},
|
28
27
|
}
|
29
28
|
end
|
@@ -57,55 +56,54 @@ module Jekyll
|
|
57
56
|
end
|
58
57
|
|
59
58
|
# Read archive data from collection
|
60
|
-
def read(
|
61
|
-
if enabled?(
|
62
|
-
|
63
|
-
|
59
|
+
def read(collection)
|
60
|
+
if @config[collection]["enabled"].is_a?(Array)
|
61
|
+
if enabled?(collection, "year") || enabled?(collection, "month") || enabled?(collection, "day")
|
62
|
+
read_dates(collection)
|
63
|
+
end
|
64
64
|
|
65
|
-
|
66
|
-
|
67
|
-
end
|
65
|
+
# read all attributes that are not year, month, or day
|
66
|
+
attributes = @config[collection]["enabled"].select { |attr| !["year", "month", "day"].include?(attr) }
|
68
67
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
68
|
+
attributes.each do |attr|
|
69
|
+
read_attrs(collection, attr)
|
70
|
+
end
|
71
|
+
|
72
|
+
elsif @config[collection]["enabled"] == true || @config[collection]["enabled"] == "all"
|
73
|
+
read_dates(collection)
|
73
74
|
|
74
|
-
|
75
|
-
|
76
|
-
|
75
|
+
# create a list of all attributes
|
76
|
+
attributes = @collections[collection].docs.flat_map { |doc| doc.data.keys }.uniq
|
77
|
+
# discard any attribute that is not an array
|
78
|
+
attributes.reject! { |attr| @collections[collection].docs.all? { |doc| !doc.data[attr].is_a?(Array) } }
|
79
|
+
|
80
|
+
attributes.each do |attr|
|
81
|
+
read_attrs(collection, attr)
|
82
|
+
end
|
77
83
|
end
|
78
84
|
end
|
79
85
|
|
80
|
-
def
|
81
|
-
|
82
|
-
@archives << Archive.new(@site, title,
|
86
|
+
def read_attrs(collection, attr)
|
87
|
+
doc_attr_hash(@collections[collection], attr).each do |title, documents|
|
88
|
+
@archives << Archive.new(@site, title, attr, collection, documents)
|
83
89
|
end
|
84
90
|
end
|
85
91
|
|
86
|
-
def read_dates(
|
87
|
-
years(@collections[
|
88
|
-
append_enabled_date_type({ :year => year }, "year",
|
92
|
+
def read_dates(collection)
|
93
|
+
years(@collections[collection]).each do |year, y_documents|
|
94
|
+
append_enabled_date_type({ :year => year }, "year", collection, y_documents)
|
89
95
|
months(y_documents).each do |month, m_documents|
|
90
|
-
append_enabled_date_type({ :year => year, :month => month }, "month",
|
96
|
+
append_enabled_date_type({ :year => year, :month => month }, "month", collection, m_documents)
|
91
97
|
days(m_documents).each do |day, d_documents|
|
92
|
-
append_enabled_date_type({ :year => year, :month => month, :day => day }, "day",
|
98
|
+
append_enabled_date_type({ :year => year, :month => month, :day => day }, "day", collection, d_documents)
|
93
99
|
end
|
94
100
|
end
|
95
101
|
end
|
96
102
|
end
|
97
103
|
|
98
104
|
# Checks if archive type is enabled in config
|
99
|
-
def enabled?(
|
100
|
-
@config[
|
101
|
-
end
|
102
|
-
|
103
|
-
def tags(documents)
|
104
|
-
doc_attr_hash(documents, "tags")
|
105
|
-
end
|
106
|
-
|
107
|
-
def categories(documents)
|
108
|
-
doc_attr_hash(documents, "categories")
|
105
|
+
def enabled?(collection, archive)
|
106
|
+
@config[collection]["enabled"] == true || @config[collection]["enabled"] == "all" || (@config[collection]["enabled"].is_a?(Array) && @config[collection]["enabled"].include?(archive))
|
109
107
|
end
|
110
108
|
|
111
109
|
# Custom `post_attr_hash` method for years
|
@@ -128,12 +126,12 @@ module Jekyll
|
|
128
126
|
# Initialize a new Archive page and append to base array if the associated date `type`
|
129
127
|
# has been enabled by configuration.
|
130
128
|
#
|
131
|
-
# meta
|
132
|
-
# type
|
133
|
-
#
|
134
|
-
# documents
|
135
|
-
def append_enabled_date_type(meta, type,
|
136
|
-
@archives << Archive.new(@site, meta, type,
|
129
|
+
# meta - A Hash of the year / month / day as applicable for date.
|
130
|
+
# type - The type of date archive.
|
131
|
+
# collection - the name of the collection
|
132
|
+
# documents - The array of documents that belong in the date archive.
|
133
|
+
def append_enabled_date_type(meta, type, collection, documents)
|
134
|
+
@archives << Archive.new(@site, meta, type, collection, documents) if enabled?(collection, type)
|
137
135
|
end
|
138
136
|
|
139
137
|
# Custom `post_attr_hash` for date type archives.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-archives-v2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- George Corrêa de Araújo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -30,6 +30,20 @@ dependencies:
|
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '5.0'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: activesupport
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
33
47
|
- !ruby/object:Gem::Dependency
|
34
48
|
name: bundler
|
35
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -124,10 +138,14 @@ files:
|
|
124
138
|
- lib/jekyll-archives-v2/archive.rb
|
125
139
|
- lib/jekyll-archives-v2/page_drop.rb
|
126
140
|
- lib/jekyll-archives-v2/version.rb
|
127
|
-
homepage: https://
|
141
|
+
homepage: https://george-gca.github.io/jekyll-archives-v2/
|
128
142
|
licenses:
|
129
143
|
- MIT
|
130
|
-
metadata:
|
144
|
+
metadata:
|
145
|
+
source_code_uri: https://github.com/george-gca/jekyll-archives-v2
|
146
|
+
bug_tracker_uri: https://github.com/george-gca/jekyll-archives-v2/issues
|
147
|
+
changelog_uri: https://github.com/george-gca/jekyll-archives-v2/releases
|
148
|
+
homepage_uri: https://george-gca.github.io/jekyll-archives-v2/
|
131
149
|
post_install_message:
|
132
150
|
rdoc_options: []
|
133
151
|
require_paths:
|