bridgetown-core 0.21.2 → 0.21.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bridgetown-core/frontmatter_defaults.rb +11 -11
- data/lib/bridgetown-core/resource/base.rb +17 -16
- data/lib/bridgetown-core/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93f29ed24b8de3b277f80f77581605e3e0ed4aa8a40f87bb5b3e3cbc68fa8dfa
|
4
|
+
data.tar.gz: 9da3d6b3c608d7b067fdd9a65f6c05f1f40479c752d5c4fc5c523bcb9074e41b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63578f5534657f1ce647edd2f8d63ab7603d95d2ab3e2090a67baee046aa851f25eebca7d140525e39d5291f7101a286e0667eddedfe3dbbfe25a9f5a965f6ec
|
7
|
+
data.tar.gz: a0d39c95cd660de86debb328c6aecd8e884ef2154caedd5e8d61b5de7c9268e3df4feb4c7f2ebc0706ec5d7eef40ce40b46be38190ce68a7679d42abd4dffd68
|
@@ -1,13 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Bridgetown
|
4
|
-
# This class handles custom defaults for YAML frontmatter
|
5
|
-
# These are set in bridgetown.config.yml and apply both to internal use (e.g. layout)
|
6
|
-
# and the data available to liquid.
|
7
|
-
#
|
4
|
+
# This class handles custom defaults for YAML frontmatter variables.
|
8
5
|
# It is exposed via the frontmatter_defaults method on the site class.
|
6
|
+
# TODO: needs simplification/refactoring.
|
9
7
|
class FrontmatterDefaults
|
10
|
-
#
|
8
|
+
# @return [Bridgetown::Site]
|
9
|
+
attr_reader :site
|
10
|
+
|
11
11
|
def initialize(site)
|
12
12
|
@site = site
|
13
13
|
end
|
@@ -45,7 +45,7 @@ module Bridgetown
|
|
45
45
|
set
|
46
46
|
end
|
47
47
|
|
48
|
-
#
|
48
|
+
# TODO: deprecated. See `all` method instead
|
49
49
|
#
|
50
50
|
# path - the path (relative to the source) of the page or
|
51
51
|
# post the default is used in
|
@@ -96,8 +96,8 @@ module Bridgetown
|
|
96
96
|
private
|
97
97
|
|
98
98
|
def merge_data_cascade_for_path(path, merged_data)
|
99
|
-
absolute_path =
|
100
|
-
|
99
|
+
absolute_path = site.in_source_dir(path)
|
100
|
+
site.defaults_reader.path_defaults
|
101
101
|
.select { |k, _v| absolute_path.include? k }
|
102
102
|
.sort_by { |k, _v| k.length }
|
103
103
|
.each do |defaults|
|
@@ -130,7 +130,7 @@ module Bridgetown
|
|
130
130
|
end
|
131
131
|
|
132
132
|
def glob_scope(sanitized_path, rel_scope_path)
|
133
|
-
site_source = Pathname.new(
|
133
|
+
site_source = Pathname.new(site.source)
|
134
134
|
abs_scope_path = site_source.join(rel_scope_path).to_s
|
135
135
|
|
136
136
|
glob_cache(abs_scope_path).each do |scope_path|
|
@@ -152,7 +152,7 @@ module Bridgetown
|
|
152
152
|
end
|
153
153
|
|
154
154
|
def strip_collections_dir(path)
|
155
|
-
collections_dir =
|
155
|
+
collections_dir = site.config["collections_dir"]
|
156
156
|
slashed_coll_dir = collections_dir.empty? ? "/" : "#{collections_dir}/"
|
157
157
|
return path if collections_dir.empty? || !path.to_s.start_with?(slashed_coll_dir)
|
158
158
|
|
@@ -226,7 +226,7 @@ module Bridgetown
|
|
226
226
|
#
|
227
227
|
# Returns an array of hashes
|
228
228
|
def valid_sets
|
229
|
-
sets =
|
229
|
+
sets = site.config["defaults"]
|
230
230
|
return [] unless sets.is_a?(Array)
|
231
231
|
|
232
232
|
sets.map do |set|
|
@@ -30,9 +30,9 @@ module Bridgetown
|
|
30
30
|
def initialize(model:)
|
31
31
|
@model = model
|
32
32
|
@site = model.site
|
33
|
-
|
33
|
+
@data = front_matter_defaults
|
34
34
|
|
35
|
-
trigger_hooks
|
35
|
+
trigger_hooks :post_init
|
36
36
|
end
|
37
37
|
|
38
38
|
# Collection associated with this resource
|
@@ -75,20 +75,21 @@ module Bridgetown
|
|
75
75
|
@relations ||= Bridgetown::Resource::Relations.new(self)
|
76
76
|
end
|
77
77
|
|
78
|
+
# Loads in any default front matter associated with the resource.
|
79
|
+
#
|
80
|
+
# @return [HashWithDotAccess::Hash]
|
81
|
+
def front_matter_defaults
|
82
|
+
site.frontmatter_defaults.all(
|
83
|
+
relative_path.to_s,
|
84
|
+
collection.label.to_sym
|
85
|
+
).with_dot_access
|
86
|
+
end
|
87
|
+
|
88
|
+
# Merges new data into the existing data hash.
|
89
|
+
#
|
78
90
|
# @param new_data [HashWithDotAccess::Hash]
|
79
91
|
def data=(new_data)
|
80
|
-
|
81
|
-
raise "#{self.class} data should be of type HashWithDotAccess::Hash"
|
82
|
-
end
|
83
|
-
|
84
|
-
@data = new_data
|
85
|
-
@data.default_proc = proc do |_, key|
|
86
|
-
site.frontmatter_defaults.find(
|
87
|
-
relative_path.to_s,
|
88
|
-
collection.label.to_sym,
|
89
|
-
key.to_s
|
90
|
-
)
|
91
|
-
end
|
92
|
+
@data = @data.merge(new_data)
|
92
93
|
end
|
93
94
|
|
94
95
|
# @return [Bridgetown::Resource::Base]
|
@@ -107,7 +108,7 @@ module Bridgetown
|
|
107
108
|
|
108
109
|
@destination = Destination.new(self) if requires_destination?
|
109
110
|
|
110
|
-
trigger_hooks
|
111
|
+
trigger_hooks :post_read
|
111
112
|
|
112
113
|
self
|
113
114
|
end
|
@@ -188,7 +189,7 @@ module Bridgetown
|
|
188
189
|
def summary
|
189
190
|
return summary_extension_output if respond_to?(:summary_extension_output)
|
190
191
|
|
191
|
-
content.to_s.strip.lines.first.to_s.strip
|
192
|
+
content.to_s.strip.lines.first.to_s.strip.html_safe
|
192
193
|
end
|
193
194
|
|
194
195
|
# @return [Hash<String, Hash<String => Bridgetown::Resource::TaxonomyType,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bridgetown-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.21.
|
4
|
+
version: 0.21.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bridgetown Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-07
|
11
|
+
date: 2021-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|