jekyll 4.0.1 → 4.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +350 -163
- data/LICENSE +21 -21
- data/README.markdown +86 -90
- data/exe/jekyll +57 -57
- data/lib/blank_template/_config.yml +3 -3
- data/lib/blank_template/_layouts/default.html +12 -12
- data/lib/blank_template/_sass/main.scss +9 -9
- data/lib/blank_template/assets/css/main.scss +4 -4
- data/lib/blank_template/index.md +8 -8
- data/lib/jekyll/cache.rb +190 -190
- data/lib/jekyll/cleaner.rb +111 -111
- data/lib/jekyll/collection.rb +309 -309
- data/lib/jekyll/command.rb +105 -103
- data/lib/jekyll/commands/build.rb +93 -93
- data/lib/jekyll/commands/clean.rb +45 -45
- data/lib/jekyll/commands/doctor.rb +177 -173
- data/lib/jekyll/commands/help.rb +34 -34
- data/lib/jekyll/commands/new.rb +169 -169
- data/lib/jekyll/commands/new_theme.rb +40 -42
- data/lib/jekyll/commands/serve/live_reload_reactor.rb +122 -122
- data/lib/jekyll/commands/serve/livereload_assets/livereload.js +1183 -1183
- data/lib/jekyll/commands/serve/servlet.rb +202 -202
- data/lib/jekyll/commands/serve/websockets.rb +81 -81
- data/lib/jekyll/commands/serve.rb +362 -354
- data/lib/jekyll/configuration.rb +313 -316
- data/lib/jekyll/converter.rb +54 -54
- data/lib/jekyll/converters/identity.rb +41 -41
- data/lib/jekyll/converters/markdown/kramdown_parser.rb +199 -130
- data/lib/jekyll/converters/markdown.rb +113 -113
- data/lib/jekyll/converters/smartypants.rb +70 -70
- data/lib/jekyll/convertible.rb +257 -254
- data/lib/jekyll/deprecator.rb +50 -50
- data/lib/jekyll/document.rb +544 -522
- data/lib/jekyll/drops/collection_drop.rb +20 -20
- data/lib/jekyll/drops/document_drop.rb +70 -69
- data/lib/jekyll/drops/drop.rb +293 -215
- data/lib/jekyll/drops/excerpt_drop.rb +19 -19
- data/lib/jekyll/drops/jekyll_drop.rb +32 -32
- data/lib/jekyll/drops/site_drop.rb +66 -66
- data/lib/jekyll/drops/static_file_drop.rb +14 -14
- data/lib/jekyll/drops/unified_payload_drop.rb +26 -26
- data/lib/jekyll/drops/url_drop.rb +140 -132
- data/lib/jekyll/entry_filter.rb +121 -110
- data/lib/jekyll/errors.rb +20 -20
- data/lib/jekyll/excerpt.rb +201 -201
- data/lib/jekyll/external.rb +79 -79
- data/lib/jekyll/filters/date_filters.rb +110 -110
- data/lib/jekyll/filters/grouping_filters.rb +64 -64
- data/lib/jekyll/filters/url_filters.rb +98 -68
- data/lib/jekyll/filters.rb +535 -454
- data/lib/jekyll/frontmatter_defaults.rb +240 -245
- data/lib/jekyll/generator.rb +5 -5
- data/lib/jekyll/hooks.rb +107 -106
- data/lib/jekyll/inclusion.rb +32 -0
- data/lib/jekyll/layout.rb +67 -62
- data/lib/jekyll/liquid_extensions.rb +22 -22
- data/lib/jekyll/liquid_renderer/file.rb +77 -77
- data/lib/jekyll/liquid_renderer/table.rb +55 -75
- data/lib/jekyll/liquid_renderer.rb +80 -77
- data/lib/jekyll/log_adapter.rb +151 -151
- data/lib/jekyll/mime.types +866 -866
- data/lib/jekyll/page.rb +217 -186
- data/lib/jekyll/page_excerpt.rb +25 -0
- data/lib/jekyll/page_without_a_file.rb +14 -14
- data/lib/jekyll/path_manager.rb +74 -31
- data/lib/jekyll/plugin.rb +92 -92
- data/lib/jekyll/plugin_manager.rb +115 -115
- data/lib/jekyll/profiler.rb +58 -0
- data/lib/jekyll/publisher.rb +23 -23
- data/lib/jekyll/reader.rb +192 -187
- data/lib/jekyll/readers/collection_reader.rb +23 -22
- data/lib/jekyll/readers/data_reader.rb +79 -75
- data/lib/jekyll/readers/layout_reader.rb +62 -61
- data/lib/jekyll/readers/page_reader.rb +25 -24
- data/lib/jekyll/readers/post_reader.rb +85 -84
- data/lib/jekyll/readers/static_file_reader.rb +25 -24
- data/lib/jekyll/readers/theme_assets_reader.rb +52 -51
- data/lib/jekyll/regenerator.rb +195 -195
- data/lib/jekyll/related_posts.rb +52 -52
- data/lib/jekyll/renderer.rb +265 -267
- data/lib/jekyll/site.rb +551 -527
- data/lib/jekyll/static_file.rb +208 -203
- data/lib/jekyll/stevenson.rb +60 -60
- data/lib/jekyll/tags/highlight.rb +110 -110
- data/lib/jekyll/tags/include.rb +275 -221
- data/lib/jekyll/tags/link.rb +42 -41
- data/lib/jekyll/tags/post_url.rb +106 -107
- data/lib/jekyll/theme.rb +86 -80
- data/lib/jekyll/theme_builder.rb +121 -121
- data/lib/jekyll/url.rb +167 -164
- data/lib/jekyll/utils/ansi.rb +57 -57
- data/lib/jekyll/utils/exec.rb +26 -26
- data/lib/jekyll/utils/internet.rb +37 -37
- data/lib/jekyll/utils/platforms.rb +67 -82
- data/lib/jekyll/utils/thread_event.rb +31 -31
- data/lib/jekyll/utils/win_tz.rb +75 -75
- data/lib/jekyll/utils.rb +367 -367
- data/lib/jekyll/version.rb +5 -5
- data/lib/jekyll.rb +195 -206
- data/lib/site_template/.gitignore +5 -5
- data/lib/site_template/404.html +25 -25
- data/lib/site_template/_config.yml +55 -55
- data/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb +29 -29
- data/lib/site_template/about.markdown +18 -18
- data/lib/site_template/index.markdown +6 -6
- data/lib/theme_template/CODE_OF_CONDUCT.md.erb +74 -74
- data/lib/theme_template/Gemfile +4 -4
- data/lib/theme_template/LICENSE.txt.erb +21 -21
- data/lib/theme_template/README.md.erb +52 -52
- data/lib/theme_template/_layouts/default.html +1 -1
- data/lib/theme_template/_layouts/page.html +5 -5
- data/lib/theme_template/_layouts/post.html +5 -5
- data/lib/theme_template/example/_config.yml.erb +1 -1
- data/lib/theme_template/example/_post.md +12 -12
- data/lib/theme_template/example/index.html +14 -14
- data/lib/theme_template/example/style.scss +7 -7
- data/lib/theme_template/gitignore.erb +6 -6
- data/lib/theme_template/theme.gemspec.erb +16 -19
- data/rubocop/jekyll/assert_equal_literal_actual.rb +149 -149
- data/rubocop/jekyll/no_p_allowed.rb +23 -23
- data/rubocop/jekyll/no_puts_allowed.rb +23 -23
- data/rubocop/jekyll.rb +5 -5
- metadata +20 -38
@@ -1,245 +1,240 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Jekyll
|
4
|
-
# This class handles custom defaults for YAML frontmatter settings.
|
5
|
-
# These are set in _config.yml and apply both to internal use (e.g. layout)
|
6
|
-
# and the data available to liquid.
|
7
|
-
#
|
8
|
-
# It is exposed via the frontmatter_defaults method on the site class.
|
9
|
-
class FrontmatterDefaults
|
10
|
-
# Initializes a new instance.
|
11
|
-
def initialize(site)
|
12
|
-
@site = site
|
13
|
-
end
|
14
|
-
|
15
|
-
def reset
|
16
|
-
@glob_cache = {} if @glob_cache
|
17
|
-
end
|
18
|
-
|
19
|
-
def update_deprecated_types(set)
|
20
|
-
return set unless set.key?("scope") && set["scope"].key?("type")
|
21
|
-
|
22
|
-
set["scope"]["type"] =
|
23
|
-
case set["scope"]["type"]
|
24
|
-
when "page"
|
25
|
-
Deprecator.defaults_deprecate_type("page", "pages")
|
26
|
-
"pages"
|
27
|
-
when "post"
|
28
|
-
Deprecator.defaults_deprecate_type("post", "posts")
|
29
|
-
"posts"
|
30
|
-
when "draft"
|
31
|
-
Deprecator.defaults_deprecate_type("draft", "drafts")
|
32
|
-
"drafts"
|
33
|
-
else
|
34
|
-
set["scope"]["type"]
|
35
|
-
end
|
36
|
-
|
37
|
-
set
|
38
|
-
end
|
39
|
-
|
40
|
-
def ensure_time!(set)
|
41
|
-
return set unless set.key?("values") && set["values"].key?("date")
|
42
|
-
return set if set["values"]["date"].is_a?(Time)
|
43
|
-
|
44
|
-
set["values"]["date"] = Utils.parse_date(
|
45
|
-
set["values"]["date"],
|
46
|
-
"An invalid date format was found in a front-matter default set: #{set}"
|
47
|
-
)
|
48
|
-
set
|
49
|
-
end
|
50
|
-
|
51
|
-
# Finds a default value for a given setting, filtered by path and type
|
52
|
-
#
|
53
|
-
# path - the path (relative to the source) of the page,
|
54
|
-
# post or :draft the default is used in
|
55
|
-
# type - a symbol indicating whether a :page,
|
56
|
-
# a :post or a :draft calls this method
|
57
|
-
#
|
58
|
-
# Returns the default value or nil if none was found
|
59
|
-
def find(path, type, setting)
|
60
|
-
value = nil
|
61
|
-
old_scope = nil
|
62
|
-
|
63
|
-
matching_sets(path, type).each do |set|
|
64
|
-
if set["values"].key?(setting) && has_precedence?(old_scope, set["scope"])
|
65
|
-
value = set["values"][setting]
|
66
|
-
old_scope = set["scope"]
|
67
|
-
end
|
68
|
-
end
|
69
|
-
value
|
70
|
-
end
|
71
|
-
|
72
|
-
# Collects a hash with all default values for a page or post
|
73
|
-
#
|
74
|
-
# path - the relative path of the page or post
|
75
|
-
# type - a symbol indicating the type (:post, :page or :draft)
|
76
|
-
#
|
77
|
-
# Returns a hash with all default values (an empty hash if there are none)
|
78
|
-
def all(path, type)
|
79
|
-
defaults = {}
|
80
|
-
old_scope = nil
|
81
|
-
matching_sets(path, type).each do |set|
|
82
|
-
if has_precedence?(old_scope, set["scope"])
|
83
|
-
defaults = Utils.deep_merge_hashes(defaults, set["values"])
|
84
|
-
old_scope = set["scope"]
|
85
|
-
else
|
86
|
-
defaults = Utils.deep_merge_hashes(set["values"], defaults)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
defaults
|
90
|
-
end
|
91
|
-
|
92
|
-
private
|
93
|
-
|
94
|
-
# Checks if a given default setting scope matches the given path and type
|
95
|
-
#
|
96
|
-
# scope - the hash indicating the scope, as defined in _config.yml
|
97
|
-
# path - the path to check for
|
98
|
-
# type - the type (:post, :page or :draft) to check for
|
99
|
-
#
|
100
|
-
# Returns true if the scope applies to the given type and path
|
101
|
-
def applies?(scope, path, type)
|
102
|
-
applies_type?(scope, type) && applies_path?(scope, path)
|
103
|
-
end
|
104
|
-
|
105
|
-
def applies_path?(scope, path)
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
if
|
112
|
-
glob_scope(sanitized_path, rel_scope_path)
|
113
|
-
else
|
114
|
-
path_is_subpath?(sanitized_path, strip_collections_dir(
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
def glob_scope(sanitized_path, rel_scope_path)
|
119
|
-
site_source = Pathname.new(@site.source)
|
120
|
-
abs_scope_path = site_source.join(rel_scope_path).to_s
|
121
|
-
|
122
|
-
glob_cache(abs_scope_path).each do |scope_path|
|
123
|
-
scope_path = Pathname.new(scope_path).relative_path_from(site_source).to_s
|
124
|
-
scope_path = strip_collections_dir(scope_path)
|
125
|
-
Jekyll.logger.debug "Globbed Scope Path:", scope_path
|
126
|
-
return true if path_is_subpath?(sanitized_path, scope_path)
|
127
|
-
end
|
128
|
-
false
|
129
|
-
end
|
130
|
-
|
131
|
-
def glob_cache(path)
|
132
|
-
@glob_cache ||= {}
|
133
|
-
@glob_cache[path] ||= Dir.glob(path)
|
134
|
-
end
|
135
|
-
|
136
|
-
def path_is_subpath?(path, parent_path)
|
137
|
-
path.
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
#
|
153
|
-
#
|
154
|
-
#
|
155
|
-
#
|
156
|
-
#
|
157
|
-
#
|
158
|
-
#
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
#
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
#
|
177
|
-
#
|
178
|
-
#
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
#
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
#
|
213
|
-
#
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
path.gsub(SANITIZATION_REGEX, "")
|
242
|
-
end
|
243
|
-
end
|
244
|
-
end
|
245
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
# This class handles custom defaults for YAML frontmatter settings.
|
5
|
+
# These are set in _config.yml and apply both to internal use (e.g. layout)
|
6
|
+
# and the data available to liquid.
|
7
|
+
#
|
8
|
+
# It is exposed via the frontmatter_defaults method on the site class.
|
9
|
+
class FrontmatterDefaults
|
10
|
+
# Initializes a new instance.
|
11
|
+
def initialize(site)
|
12
|
+
@site = site
|
13
|
+
end
|
14
|
+
|
15
|
+
def reset
|
16
|
+
@glob_cache = {} if @glob_cache
|
17
|
+
end
|
18
|
+
|
19
|
+
def update_deprecated_types(set)
|
20
|
+
return set unless set.key?("scope") && set["scope"].key?("type")
|
21
|
+
|
22
|
+
set["scope"]["type"] =
|
23
|
+
case set["scope"]["type"]
|
24
|
+
when "page"
|
25
|
+
Deprecator.defaults_deprecate_type("page", "pages")
|
26
|
+
"pages"
|
27
|
+
when "post"
|
28
|
+
Deprecator.defaults_deprecate_type("post", "posts")
|
29
|
+
"posts"
|
30
|
+
when "draft"
|
31
|
+
Deprecator.defaults_deprecate_type("draft", "drafts")
|
32
|
+
"drafts"
|
33
|
+
else
|
34
|
+
set["scope"]["type"]
|
35
|
+
end
|
36
|
+
|
37
|
+
set
|
38
|
+
end
|
39
|
+
|
40
|
+
def ensure_time!(set)
|
41
|
+
return set unless set.key?("values") && set["values"].key?("date")
|
42
|
+
return set if set["values"]["date"].is_a?(Time)
|
43
|
+
|
44
|
+
set["values"]["date"] = Utils.parse_date(
|
45
|
+
set["values"]["date"],
|
46
|
+
"An invalid date format was found in a front-matter default set: #{set}"
|
47
|
+
)
|
48
|
+
set
|
49
|
+
end
|
50
|
+
|
51
|
+
# Finds a default value for a given setting, filtered by path and type
|
52
|
+
#
|
53
|
+
# path - the path (relative to the source) of the page,
|
54
|
+
# post or :draft the default is used in
|
55
|
+
# type - a symbol indicating whether a :page,
|
56
|
+
# a :post or a :draft calls this method
|
57
|
+
#
|
58
|
+
# Returns the default value or nil if none was found
|
59
|
+
def find(path, type, setting)
|
60
|
+
value = nil
|
61
|
+
old_scope = nil
|
62
|
+
|
63
|
+
matching_sets(path, type).each do |set|
|
64
|
+
if set["values"].key?(setting) && has_precedence?(old_scope, set["scope"])
|
65
|
+
value = set["values"][setting]
|
66
|
+
old_scope = set["scope"]
|
67
|
+
end
|
68
|
+
end
|
69
|
+
value
|
70
|
+
end
|
71
|
+
|
72
|
+
# Collects a hash with all default values for a page or post
|
73
|
+
#
|
74
|
+
# path - the relative path of the page or post
|
75
|
+
# type - a symbol indicating the type (:post, :page or :draft)
|
76
|
+
#
|
77
|
+
# Returns a hash with all default values (an empty hash if there are none)
|
78
|
+
def all(path, type)
|
79
|
+
defaults = {}
|
80
|
+
old_scope = nil
|
81
|
+
matching_sets(path, type).each do |set|
|
82
|
+
if has_precedence?(old_scope, set["scope"])
|
83
|
+
defaults = Utils.deep_merge_hashes(defaults, set["values"])
|
84
|
+
old_scope = set["scope"]
|
85
|
+
else
|
86
|
+
defaults = Utils.deep_merge_hashes(set["values"], defaults)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
defaults
|
90
|
+
end
|
91
|
+
|
92
|
+
private
|
93
|
+
|
94
|
+
# Checks if a given default setting scope matches the given path and type
|
95
|
+
#
|
96
|
+
# scope - the hash indicating the scope, as defined in _config.yml
|
97
|
+
# path - the path to check for
|
98
|
+
# type - the type (:post, :page or :draft) to check for
|
99
|
+
#
|
100
|
+
# Returns true if the scope applies to the given type and path
|
101
|
+
def applies?(scope, path, type)
|
102
|
+
applies_type?(scope, type) && applies_path?(scope, path)
|
103
|
+
end
|
104
|
+
|
105
|
+
def applies_path?(scope, path)
|
106
|
+
rel_scope_path = scope["path"]
|
107
|
+
return true if !rel_scope_path.is_a?(String) || rel_scope_path.empty?
|
108
|
+
|
109
|
+
sanitized_path = sanitize_path(path)
|
110
|
+
|
111
|
+
if rel_scope_path.include?("*")
|
112
|
+
glob_scope(sanitized_path, rel_scope_path)
|
113
|
+
else
|
114
|
+
path_is_subpath?(sanitized_path, strip_collections_dir(rel_scope_path))
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def glob_scope(sanitized_path, rel_scope_path)
|
119
|
+
site_source = Pathname.new(@site.source)
|
120
|
+
abs_scope_path = site_source.join(rel_scope_path).to_s
|
121
|
+
|
122
|
+
glob_cache(abs_scope_path).each do |scope_path|
|
123
|
+
scope_path = Pathname.new(scope_path).relative_path_from(site_source).to_s
|
124
|
+
scope_path = strip_collections_dir(scope_path)
|
125
|
+
Jekyll.logger.debug "Globbed Scope Path:", scope_path
|
126
|
+
return true if path_is_subpath?(sanitized_path, scope_path)
|
127
|
+
end
|
128
|
+
false
|
129
|
+
end
|
130
|
+
|
131
|
+
def glob_cache(path)
|
132
|
+
@glob_cache ||= {}
|
133
|
+
@glob_cache[path] ||= Dir.glob(path)
|
134
|
+
end
|
135
|
+
|
136
|
+
def path_is_subpath?(path, parent_path)
|
137
|
+
path.start_with?(parent_path)
|
138
|
+
end
|
139
|
+
|
140
|
+
def strip_collections_dir(path)
|
141
|
+
collections_dir = @site.config["collections_dir"]
|
142
|
+
slashed_coll_dir = collections_dir.empty? ? "/" : "#{collections_dir}/"
|
143
|
+
return path if collections_dir.empty? || !path.to_s.start_with?(slashed_coll_dir)
|
144
|
+
|
145
|
+
path.sub(slashed_coll_dir, "")
|
146
|
+
end
|
147
|
+
|
148
|
+
# Determines whether the scope applies to type.
|
149
|
+
# The scope applies to the type if:
|
150
|
+
# 1. no 'type' is specified
|
151
|
+
# 2. the 'type' in the scope is the same as the type asked about
|
152
|
+
#
|
153
|
+
# scope - the Hash defaults set being asked about application
|
154
|
+
# type - the type of the document being processed / asked about
|
155
|
+
# its defaults.
|
156
|
+
#
|
157
|
+
# Returns true if either of the above conditions are satisfied,
|
158
|
+
# otherwise returns false
|
159
|
+
def applies_type?(scope, type)
|
160
|
+
!scope.key?("type") || type&.to_sym.eql?(scope["type"].to_sym)
|
161
|
+
end
|
162
|
+
|
163
|
+
# Checks if a given set of default values is valid
|
164
|
+
#
|
165
|
+
# set - the default value hash, as defined in _config.yml
|
166
|
+
#
|
167
|
+
# Returns true if the set is valid and can be used in this class
|
168
|
+
def valid?(set)
|
169
|
+
set.is_a?(Hash) && set["values"].is_a?(Hash)
|
170
|
+
end
|
171
|
+
|
172
|
+
# Determines if a new scope has precedence over an old one
|
173
|
+
#
|
174
|
+
# old_scope - the old scope hash, or nil if there's none
|
175
|
+
# new_scope - the new scope hash
|
176
|
+
#
|
177
|
+
# Returns true if the new scope has precedence over the older
|
178
|
+
# rubocop: disable Naming/PredicateName
|
179
|
+
def has_precedence?(old_scope, new_scope)
|
180
|
+
return true if old_scope.nil?
|
181
|
+
|
182
|
+
new_path = sanitize_path(new_scope["path"])
|
183
|
+
old_path = sanitize_path(old_scope["path"])
|
184
|
+
|
185
|
+
if new_path.length != old_path.length
|
186
|
+
new_path.length >= old_path.length
|
187
|
+
elsif new_scope.key?("type")
|
188
|
+
true
|
189
|
+
else
|
190
|
+
!old_scope.key? "type"
|
191
|
+
end
|
192
|
+
end
|
193
|
+
# rubocop: enable Naming/PredicateName
|
194
|
+
|
195
|
+
# Collects a list of sets that match the given path and type
|
196
|
+
#
|
197
|
+
# Returns an array of hashes
|
198
|
+
def matching_sets(path, type)
|
199
|
+
@matched_set_cache ||= {}
|
200
|
+
@matched_set_cache[path] ||= {}
|
201
|
+
@matched_set_cache[path][type] ||= begin
|
202
|
+
valid_sets.select do |set|
|
203
|
+
!set.key?("scope") || applies?(set["scope"], path, type)
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
# Returns a list of valid sets
|
209
|
+
#
|
210
|
+
# This is not cached to allow plugins to modify the configuration
|
211
|
+
# and have their changes take effect
|
212
|
+
#
|
213
|
+
# Returns an array of hashes
|
214
|
+
def valid_sets
|
215
|
+
sets = @site.config["defaults"]
|
216
|
+
return [] unless sets.is_a?(Array)
|
217
|
+
|
218
|
+
sets.map do |set|
|
219
|
+
if valid?(set)
|
220
|
+
ensure_time!(update_deprecated_types(set))
|
221
|
+
else
|
222
|
+
Jekyll.logger.warn "Defaults:", "An invalid front-matter default set was found:"
|
223
|
+
Jekyll.logger.warn set.to_s
|
224
|
+
nil
|
225
|
+
end
|
226
|
+
end.tap(&:compact!)
|
227
|
+
end
|
228
|
+
|
229
|
+
# Sanitizes the given path by removing a leading slash
|
230
|
+
def sanitize_path(path)
|
231
|
+
if path.nil? || path.empty?
|
232
|
+
""
|
233
|
+
elsif path.start_with?("/")
|
234
|
+
path.gsub(%r!\A/|(?<=[^/])\z!, "")
|
235
|
+
else
|
236
|
+
path
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
data/lib/jekyll/generator.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Jekyll
|
4
|
-
Generator = Class.new(Plugin)
|
5
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
Generator = Class.new(Plugin)
|
5
|
+
end
|