bridgetown-core 0.21.1 → 0.21.5
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 +4 -4
- data/lib/bridgetown-core/concerns/site/content.rb +10 -0
- data/lib/bridgetown-core/concerns/site/processable.rb +1 -0
- data/lib/bridgetown-core/errors.rb +0 -2
- data/lib/bridgetown-core/frontmatter_defaults.rb +11 -11
- data/lib/bridgetown-core/generators/prototype_generator.rb +3 -3
- data/lib/bridgetown-core/plugin_manager.rb +8 -6
- data/lib/bridgetown-core/reader.rb +10 -5
- data/lib/bridgetown-core/resource/base.rb +17 -16
- data/lib/bridgetown-core/utils.rb +16 -22
- data/lib/bridgetown-core/version.rb +1 -1
- data/lib/site_template/frontend/javascript/index.js.erb +3 -3
- data/lib/site_template/package.json.erb +7 -4
- data/lib/site_template/start.js +3 -3
- 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: f9369cb49650eed5ad6776258f190b8afd8afa714d6dfaa77b2c6c1c15537346
|
4
|
+
data.tar.gz: f8625881a5386a7520e4e22981254352d0040d28052e2f85c64f072884da6f05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8d19b3e0926ed332e4030ddf4c039292d14f490b509708dd51f81b0cd4b177b22a819920d35a3e4f0a4924204893f36fdc00c388ef9bed28dbf672af590dc96
|
7
|
+
data.tar.gz: 25dc48e4587613c547cd12cb762c7a968efedda1905d3fca1814deeab3af2f70ebdb755c6572793e8db817cbef8e16a8d741e517ae1eb7c978da05d353492d39
|
@@ -220,5 +220,15 @@ class Bridgetown::Site
|
|
220
220
|
def add_generated_page(generated_page)
|
221
221
|
generated_pages << generated_page
|
222
222
|
end
|
223
|
+
|
224
|
+
# Loads and memoizes the parsed Webpack manifest file (if available)
|
225
|
+
# @return [Hash]
|
226
|
+
def frontend_manifest
|
227
|
+
@frontend_manifest ||= begin
|
228
|
+
manifest_file = in_root_dir(".bridgetown-webpack", "manifest.json")
|
229
|
+
|
230
|
+
JSON.parse(File.read(manifest_file)) if File.exist?(manifest_file)
|
231
|
+
end
|
232
|
+
end
|
223
233
|
end
|
224
234
|
end
|
@@ -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|
|
@@ -79,11 +79,11 @@ module Bridgetown
|
|
79
79
|
# @return [String, nil]
|
80
80
|
def validate_search_term(prototype_page)
|
81
81
|
# @type [String]
|
82
|
-
search_term = prototype_page.data["prototype"]["term"]
|
83
|
-
return nil unless search_term.
|
82
|
+
search_term = prototype_page.data["prototype"]["term"].to_s
|
83
|
+
return nil unless search_term.present?
|
84
84
|
|
85
85
|
if prototype_page.data["prototype"]["collection"]
|
86
|
-
@configured_collection = prototype_page.data["prototype"]["collection"]
|
86
|
+
@configured_collection = prototype_page.data["prototype"]["collection"].to_s
|
87
87
|
end
|
88
88
|
|
89
89
|
unless site.collections[@configured_collection]
|
@@ -173,13 +173,15 @@ module Bridgetown
|
|
173
173
|
# source components _before_ we load any from plugins
|
174
174
|
site.components_load_paths.reverse_each do |load_path|
|
175
175
|
next unless Dir.exist? load_path
|
176
|
-
next if Zeitwerk::Registry.loaders.find { |loader| loader.manages?(load_path) }
|
177
176
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
177
|
+
begin
|
178
|
+
@component_loaders[load_path] = Zeitwerk::Loader.new
|
179
|
+
@component_loaders[load_path].push_dir(load_path)
|
180
|
+
@component_loaders[load_path].enable_reloading if load_path.start_with?(site.root_dir)
|
181
|
+
@component_loaders[load_path].ignore(File.join(load_path, "**", "*.js.rb"))
|
182
|
+
@component_loaders[load_path].setup
|
183
|
+
rescue Zeitwerk::Error # rubocop:disable Lint/SuppressedException
|
184
|
+
end
|
183
185
|
end
|
184
186
|
end
|
185
187
|
# rubocop:enable Metrics/AbcSize
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
module Bridgetown
|
4
4
|
class Reader
|
5
|
+
# @return [Bridgetown::Site]
|
5
6
|
attr_reader :site
|
6
7
|
|
7
8
|
def initialize(site)
|
@@ -17,12 +18,13 @@ module Bridgetown
|
|
17
18
|
read_directories
|
18
19
|
read_included_excludes
|
19
20
|
sort_files!
|
20
|
-
read_collections
|
21
21
|
site.data = if site.uses_resource?
|
22
|
+
site.collections.data.read
|
22
23
|
site.collections.data.merge_data_resources
|
23
24
|
else
|
24
25
|
DataReader.new(site).read
|
25
26
|
end
|
27
|
+
read_collections
|
26
28
|
Bridgetown::PluginManager.source_manifests.map(&:content).compact.each do |plugin_content_dir|
|
27
29
|
PluginContentReader.new(site, plugin_content_dir).read
|
28
30
|
end
|
@@ -30,15 +32,17 @@ module Bridgetown
|
|
30
32
|
|
31
33
|
def read_collections
|
32
34
|
site.collections.each_value do |collection|
|
33
|
-
|
34
|
-
|
35
|
+
next if site.uses_resource? && collection.data?
|
36
|
+
next if !site.uses_resource? && collection.legacy_reader?
|
37
|
+
|
38
|
+
collection.read
|
35
39
|
end
|
36
40
|
end
|
37
41
|
|
38
42
|
# Sorts posts, pages, and static files.
|
39
43
|
def sort_files!
|
40
|
-
site.collections.
|
41
|
-
site.
|
44
|
+
site.collections.posts.docs.sort! unless site.uses_resource?
|
45
|
+
site.generated_pages.sort_by!(&:name)
|
42
46
|
site.static_files.sort_by!(&:relative_path)
|
43
47
|
end
|
44
48
|
|
@@ -197,6 +201,7 @@ module Bridgetown
|
|
197
201
|
dir = File.dirname(entry_path).sub(site.source, "")
|
198
202
|
file = Array(File.basename(entry_path))
|
199
203
|
if Utils.has_yaml_header?(entry_path)
|
204
|
+
# TODO: does this need to get incorporated into the resource engine?
|
200
205
|
site.pages.concat(PageReader.new(site, dir).read(file))
|
201
206
|
else
|
202
207
|
retrieve_static_files(dir, file)
|
@@ -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,
|
@@ -354,28 +354,19 @@ module Bridgetown
|
|
354
354
|
# @raise [WebpackAssetError] if unable to find css or js in the manifest
|
355
355
|
# file
|
356
356
|
def parse_webpack_manifest_file(site, asset_type)
|
357
|
-
|
358
|
-
return "MISSING_WEBPACK_MANIFEST" unless File.exist?(manifest_file)
|
357
|
+
return log_webpack_asset_error("Webpack manifest") if site.frontend_manifest.nil?
|
359
358
|
|
360
|
-
|
359
|
+
asset_path = if %w(js css).include?(asset_type)
|
360
|
+
site.frontend_manifest["main.#{asset_type}"]
|
361
|
+
else
|
362
|
+
site.frontend_manifest.find do |item, _|
|
363
|
+
item.sub(%r{^../(frontend/|src/)?}, "") == asset_type
|
364
|
+
end&.last
|
365
|
+
end
|
361
366
|
|
362
|
-
|
363
|
-
asset_path = nil
|
364
|
-
if known_assets.include?(asset_type)
|
365
|
-
asset_path = manifest["main.#{asset_type}"]
|
366
|
-
log_webpack_asset_error(asset_type) && return if asset_path.nil?
|
367
|
-
else
|
368
|
-
asset_path = manifest.find do |item, _|
|
369
|
-
item.sub(%r{^../(frontend/|src/)?}, "") == asset_type
|
370
|
-
end&.last
|
371
|
-
end
|
367
|
+
return log_webpack_asset_error(asset_type) if asset_path.nil?
|
372
368
|
|
373
|
-
|
374
|
-
static_frontend_path(site, ["js", asset_path])
|
375
|
-
else
|
376
|
-
Bridgetown.logger.error("Unknown Webpack asset type", asset_type)
|
377
|
-
nil
|
378
|
-
end
|
369
|
+
static_frontend_path site, ["js", asset_path]
|
379
370
|
end
|
380
371
|
|
381
372
|
def static_frontend_path(site, additional_parts = [])
|
@@ -389,10 +380,13 @@ module Bridgetown
|
|
389
380
|
end
|
390
381
|
|
391
382
|
def log_webpack_asset_error(asset_type)
|
392
|
-
|
393
|
-
|
383
|
+
Bridgetown.logger.warn(
|
384
|
+
"Webpack:",
|
385
|
+
"There was an error parsing your #{asset_type} file. \
|
386
|
+
Please check your #{asset_type} file for any errors."
|
387
|
+
)
|
394
388
|
|
395
|
-
|
389
|
+
"MISSING_WEBPACK_MANIFEST_FILE"
|
396
390
|
end
|
397
391
|
|
398
392
|
def default_github_branch_name(repo_url)
|
@@ -1,8 +1,8 @@
|
|
1
|
-
|
1
|
+
<%- if options["use-postcss"] -%>
|
2
2
|
import "index.css"
|
3
|
-
|
3
|
+
<%- else -%>
|
4
4
|
import "index.scss"
|
5
|
-
|
5
|
+
<%- end -%>
|
6
6
|
|
7
7
|
// Import all javascript files from src/_components
|
8
8
|
const componentsContext = require.context("bridgetownComponents", true, /.js$/)
|
@@ -20,18 +20,21 @@
|
|
20
20
|
"esbuild-loader": "^2.13.1",
|
21
21
|
"file-loader": "^6.2.0",
|
22
22
|
"mini-css-extract-plugin": "^1.3.1",
|
23
|
-
|
23
|
+
<%- if options["use-postcss"] -%>
|
24
24
|
"postcss": "^8.3.0",
|
25
25
|
"postcss-flexbugs-fixes": "^4.1.0",
|
26
26
|
"postcss-loader": "^4.3.0",
|
27
27
|
"postcss-preset-env": "^6.7.0",
|
28
|
-
|
28
|
+
<%- else -%>
|
29
29
|
"sass": "^1.32.8",
|
30
30
|
"sass-loader": "^8.0.2",
|
31
|
-
|
31
|
+
<%- end -%>
|
32
32
|
"webpack": "^5.39.1",
|
33
33
|
"webpack-cli": "^4.7.2",
|
34
|
-
"webpack-manifest-plugin": "^3.1.1"
|
34
|
+
"webpack-manifest-plugin": "^3.1.1",
|
35
35
|
"webpack-merge": "^5.8.0"
|
36
|
+
},
|
37
|
+
"resolutions": {
|
38
|
+
"postcss-focus-within": "^4.0.0"
|
36
39
|
}
|
37
40
|
}
|
data/lib/site_template/start.js
CHANGED
@@ -8,9 +8,9 @@ const port = 4001
|
|
8
8
|
// Concurrently
|
9
9
|
/////////////////
|
10
10
|
concurrently([
|
11
|
-
{ command: "yarn webpack-dev", name: "Webpack", prefixColor: "yellow"},
|
12
|
-
{ command: "sleep 4; yarn serve --port " + port, name: "Bridgetown", prefixColor: "green"},
|
13
|
-
{ command: "sleep 8; yarn sync", name: "Live", prefixColor: "blue"}
|
11
|
+
{ command: "yarn webpack-dev", name: "Webpack", prefixColor: "yellow" },
|
12
|
+
{ command: "sleep 4; yarn serve --port " + port, name: "Bridgetown", prefixColor: "green" },
|
13
|
+
{ command: "sleep 8; yarn sync", name: "Live", prefixColor: "blue" }
|
14
14
|
], {
|
15
15
|
restartTries: 3,
|
16
16
|
killOthers: ['failure', 'success'],
|
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.5
|
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-
|
11
|
+
date: 2021-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|