bridgetown-core 1.1.0.beta1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bridgetown-core.gemspec +0 -1
- data/lib/bridgetown-core/collection.rb +2 -2
- data/lib/bridgetown-core/commands/apply.rb +3 -3
- data/lib/bridgetown-core/commands/build.rb +6 -6
- data/lib/bridgetown-core/commands/concerns/build_options.rb +2 -2
- data/lib/bridgetown-core/commands/console.rb +5 -5
- data/lib/bridgetown-core/commands/doctor.rb +7 -7
- data/lib/bridgetown-core/commands/esbuild/migrate-from-webpack.rb +1 -6
- data/lib/bridgetown-core/commands/new.rb +10 -10
- data/lib/bridgetown-core/commands/plugins.rb +45 -9
- data/lib/bridgetown-core/commands/registrations.rb +2 -3
- data/lib/bridgetown-core/commands/serve.rb +2 -2
- data/lib/bridgetown-core/commands/webpack/update.rb +1 -1
- data/lib/bridgetown-core/commands/webpack/webpack.defaults.js.erb +8 -12
- data/lib/bridgetown-core/component.rb +1 -1
- data/lib/bridgetown-core/concerns/transformable.rb +2 -2
- data/lib/bridgetown-core/configuration.rb +4 -3
- data/lib/bridgetown-core/configurations/purgecss.rb +37 -25
- data/lib/bridgetown-core/configurations/shoelace.rb +25 -3
- data/lib/bridgetown-core/configurations/tailwindcss.rb +6 -4
- data/lib/bridgetown-core/configurations/turbo/turbo_transitions.js +1 -1
- data/lib/bridgetown-core/converters/erb_templates.rb +7 -2
- data/lib/bridgetown-core/converters/serbea_templates.rb +1 -4
- data/lib/bridgetown-core/model/base.rb +2 -2
- data/lib/bridgetown-core/rack/boot.rb +2 -2
- data/lib/bridgetown-core/rack/roda.rb +13 -10
- data/lib/bridgetown-core/resource/base.rb +5 -0
- data/lib/bridgetown-core/ruby_template_view.rb +3 -3
- data/lib/bridgetown-core/static_file.rb +1 -1
- data/lib/bridgetown-core/tags/highlight.rb +1 -1
- data/lib/bridgetown-core/tags/post_url.rb +1 -1
- data/lib/bridgetown-core/url.rb +1 -1
- data/lib/bridgetown-core/version.rb +1 -1
- data/lib/bridgetown-core/watcher.rb +2 -2
- data/lib/site_template/Gemfile.erb +4 -0
- data/lib/site_template/TEMPLATES/liquid/_layouts/default.liquid +1 -1
- data/lib/site_template/package.json.erb +0 -1
- metadata +4 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1a8e2712c8b2f218d0082a2d890bb53401efb354a055c323189bbefd1d9f9a6
|
4
|
+
data.tar.gz: 99d3049dabe2ba5e3e812240268fb754c842b1bbcf0acbe46345fbc1ada7194f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d820196117aad565c3dd7150c535ccd98b08b1d4cdad4b439855ea4a2666ce58f67abe67a0b68dc40959fd3e9d7eac299bf9261a43f4ef119294549bd7a95595
|
7
|
+
data.tar.gz: 40a94f0d056e35ea8f1f34d2e0f5684ed0990ee2a2804aac4d91766d2d8ead3528dbdbbf555f14035878a1287a58cf60a70e9ffc7a60a41bcf6c1cfcf9b2bf31
|
data/bridgetown-core.gemspec
CHANGED
@@ -44,7 +44,6 @@ Gem::Specification.new do |s|
|
|
44
44
|
s.add_runtime_dependency("kramdown-parser-gfm", "~> 1.0")
|
45
45
|
s.add_runtime_dependency("liquid", "~> 5.0")
|
46
46
|
s.add_runtime_dependency("listen", "~> 3.0")
|
47
|
-
s.add_runtime_dependency("rack-indifferent", ">= 1.2.0")
|
48
47
|
s.add_runtime_dependency("rake", ">= 13.0")
|
49
48
|
s.add_runtime_dependency("roda", "~> 3.46")
|
50
49
|
s.add_runtime_dependency("rouge", "~> 3.0")
|
@@ -343,8 +343,8 @@ module Bridgetown
|
|
343
343
|
end
|
344
344
|
|
345
345
|
def order_with_warning(sort_key, resource, order)
|
346
|
-
Bridgetown.logger.warn "Sort warning:", "'#{sort_key}' not defined in" \
|
347
|
-
"
|
346
|
+
Bridgetown.logger.warn "Sort warning:", "'#{sort_key}' not defined in " \
|
347
|
+
"#{resource.relative_path}"
|
348
348
|
order
|
349
349
|
end
|
350
350
|
|
@@ -58,9 +58,9 @@ module Bridgetown
|
|
58
58
|
automation_command = args.empty? ? "bridgetown.automation.rb" : args[0]
|
59
59
|
|
60
60
|
if args.empty? && !File.exist?("bridgetown.automation.rb")
|
61
|
-
raise ArgumentError, "You must specify a path or a URL," \
|
62
|
-
"
|
63
|
-
"
|
61
|
+
raise ArgumentError, "You must specify a path or a URL, " \
|
62
|
+
"or add bridgetown.automation.rb to the " \
|
63
|
+
"current folder."
|
64
64
|
end
|
65
65
|
|
66
66
|
Bridgetown.with_unbundled_env do
|
@@ -22,8 +22,8 @@ module Bridgetown
|
|
22
22
|
desc: "Watch for changes and rebuild"
|
23
23
|
|
24
24
|
def self.print_startup_message
|
25
|
-
Bridgetown.logger.info "Starting:", "Bridgetown v#{Bridgetown::VERSION.magenta}" \
|
26
|
-
"
|
25
|
+
Bridgetown.logger.info "Starting:", "Bridgetown v#{Bridgetown::VERSION.magenta} " \
|
26
|
+
"(codename \"#{Bridgetown::CODE_NAME.yellow}\")"
|
27
27
|
end
|
28
28
|
|
29
29
|
# Build your bridgetown site
|
@@ -45,8 +45,8 @@ module Bridgetown
|
|
45
45
|
@site = Bridgetown::Site.new(config_options)
|
46
46
|
|
47
47
|
if config_options.fetch("skip_initial_build", false)
|
48
|
-
Bridgetown.logger.warn "Build Warning:", "Skipping the initial build." \
|
49
|
-
"
|
48
|
+
Bridgetown.logger.warn "Build Warning:", "Skipping the initial build. " \
|
49
|
+
"This may result in an out-of-date site."
|
50
50
|
else
|
51
51
|
build_site(config_options)
|
52
52
|
end
|
@@ -77,8 +77,8 @@ module Bridgetown
|
|
77
77
|
end
|
78
78
|
Bridgetown.logger.info "Generating…"
|
79
79
|
@site.process
|
80
|
-
Bridgetown.logger.info "Done! 🎉", "#{"Completed".bold.green} in less than" \
|
81
|
-
"
|
80
|
+
Bridgetown.logger.info "Done! 🎉", "#{"Completed".bold.green} in less than " \
|
81
|
+
"#{(Time.now - t).ceil(2)} seconds."
|
82
82
|
|
83
83
|
return unless config_options[:using_puma]
|
84
84
|
|
@@ -21,8 +21,8 @@ module Bridgetown
|
|
21
21
|
desc: "Destination directory (defaults to output)"
|
22
22
|
klass.class_option :root_dir,
|
23
23
|
aliases: "-r",
|
24
|
-
desc: "The top-level root folder" \
|
25
|
-
"
|
24
|
+
desc: "The top-level root folder " \
|
25
|
+
"where config files are located"
|
26
26
|
klass.class_option :plugins_dir,
|
27
27
|
aliases: "-p",
|
28
28
|
type: :array,
|
@@ -64,9 +64,9 @@ module Bridgetown
|
|
64
64
|
require "irb/ext/save-history"
|
65
65
|
require "amazing_print" unless options[:"bypass-ap"]
|
66
66
|
|
67
|
-
Bridgetown.logger.info "Starting:", "Bridgetown v#{Bridgetown::VERSION.magenta}" \
|
68
|
-
"
|
69
|
-
"
|
67
|
+
Bridgetown.logger.info "Starting:", "Bridgetown v#{Bridgetown::VERSION.magenta} " \
|
68
|
+
"(codename \"#{Bridgetown::CODE_NAME.yellow}\") " \
|
69
|
+
"console…"
|
70
70
|
Bridgetown.logger.info "Environment:", Bridgetown.environment.cyan
|
71
71
|
site = Bridgetown::Site.new(configuration_with_overrides(options))
|
72
72
|
|
@@ -80,8 +80,8 @@ module Bridgetown
|
|
80
80
|
IRB.conf[:MAIN_CONTEXT] = irb.context
|
81
81
|
Bridgetown.logger.info "Console:", "Your site is now available as #{"site".cyan}"
|
82
82
|
Bridgetown.logger.info "",
|
83
|
-
"You can also access #{"collections".cyan} or perform a" \
|
84
|
-
"
|
83
|
+
"You can also access #{"collections".cyan} or perform a " \
|
84
|
+
"#{"reload!".cyan}"
|
85
85
|
|
86
86
|
trap("SIGINT") do
|
87
87
|
irb.signal_handle
|
@@ -62,8 +62,8 @@ module Bridgetown
|
|
62
62
|
next unless paths.size > 1
|
63
63
|
|
64
64
|
conflicting_urls = true
|
65
|
-
Bridgetown.logger.warn "Conflict:", "The URL '#{url}' is the destination" \
|
66
|
-
"
|
65
|
+
Bridgetown.logger.warn "Conflict:", "The URL '#{url}' is the destination " \
|
66
|
+
"for the following pages: #{paths.join(", ")}"
|
67
67
|
end
|
68
68
|
conflicting_urls
|
69
69
|
end
|
@@ -77,8 +77,8 @@ module Bridgetown
|
|
77
77
|
urls_only_differ_by_case = true
|
78
78
|
Bridgetown.logger.warn(
|
79
79
|
"Warning:",
|
80
|
-
"The following URLs only differ by case. On a case-insensitive file system one of
|
81
|
-
" URLs will be overwritten by the other: #{real_urls.join(", ")}"
|
80
|
+
"The following URLs only differ by case. On a case-insensitive file system one of " \
|
81
|
+
"the URLs will be overwritten by the other: #{real_urls.join(", ")}"
|
82
82
|
)
|
83
83
|
end
|
84
84
|
urls_only_differ_by_case
|
@@ -121,7 +121,7 @@ module Bridgetown
|
|
121
121
|
def url_exists?(url)
|
122
122
|
return true unless url.nil? || url.empty?
|
123
123
|
|
124
|
-
Bridgetown.logger.warn "Warning:", "You didn't set an URL in the config file, "\
|
124
|
+
Bridgetown.logger.warn "Warning:", "You didn't set an URL in the config file, " \
|
125
125
|
"you may encounter problems with some plugins."
|
126
126
|
false
|
127
127
|
end
|
@@ -132,7 +132,7 @@ module Bridgetown
|
|
132
132
|
# Addressable::URI#parse only raises a TypeError
|
133
133
|
# https://git.io/vFfbx
|
134
134
|
rescue TypeError
|
135
|
-
Bridgetown.logger.warn "Warning:", "The site URL does not seem to be valid, "\
|
135
|
+
Bridgetown.logger.warn "Warning:", "The site URL does not seem to be valid, " \
|
136
136
|
"check the value of `url` in your config file."
|
137
137
|
false
|
138
138
|
end
|
@@ -140,7 +140,7 @@ module Bridgetown
|
|
140
140
|
def url_absolute(url)
|
141
141
|
return true if url.is_a?(String) && Addressable::URI.parse(url).absolute?
|
142
142
|
|
143
|
-
Bridgetown.logger.warn "Warning:", "Your site URL does not seem to be absolute, "\
|
143
|
+
Bridgetown.logger.warn "Warning:", "Your site URL does not seem to be absolute, " \
|
144
144
|
"check the value of `url` in your config file."
|
145
145
|
false
|
146
146
|
end
|
@@ -2,11 +2,6 @@
|
|
2
2
|
|
3
3
|
# rubocop:disable Layout/LineLength
|
4
4
|
|
5
|
-
if package_json["devDependencies"].key?("sass")
|
6
|
-
say "Unable to migrate, project uses Sass. Please migrate to PostCSS first before migrating to esbuild."
|
7
|
-
return
|
8
|
-
end
|
9
|
-
|
10
5
|
remove_file "webpack.config.js"
|
11
6
|
remove_file "config/webpack.defaults.js"
|
12
7
|
|
@@ -16,7 +11,7 @@ default_postcss_config = File.expand_path("../../../site_template/postcss.config
|
|
16
11
|
template default_postcss_config, "postcss.config.js"
|
17
12
|
|
18
13
|
unless Bridgetown.environment.test?
|
19
|
-
required_packages = %w(esbuild glob postcss postcss-flexbugs-fixes postcss-preset-env postcss-import postcss-load-config)
|
14
|
+
required_packages = %w(esbuild glob postcss postcss-flexbugs-fixes postcss-preset-env postcss-import postcss-load-config@3.1.4)
|
20
15
|
redundant_packages = %w(esbuild-loader webpack webpack-cli webpack-manifest-plugin webpack-merge css-loader file-loader mini-css-extract-plugin postcss-loader)
|
21
16
|
|
22
17
|
say "Installing required packages"
|
@@ -68,8 +68,8 @@ module Bridgetown
|
|
68
68
|
if preserve_source_location?(new_site_path, options)
|
69
69
|
say_status :conflict, "#{new_site_path} exists and is not empty.", :red
|
70
70
|
Bridgetown.logger.abort_with(
|
71
|
-
"Ensure #{new_site_path} is empty or else try again with `--force` to proceed and" \
|
72
|
-
"
|
71
|
+
"Ensure #{new_site_path} is empty or else try again with `--force` to proceed and " \
|
72
|
+
"overwrite any files."
|
73
73
|
)
|
74
74
|
end
|
75
75
|
|
@@ -194,18 +194,18 @@ module Bridgetown
|
|
194
194
|
logger = Bridgetown.logger
|
195
195
|
bt_start = "bin/bridgetown start"
|
196
196
|
logger.info ""
|
197
|
-
logger.info "Success!".green, "🎉 Your new Bridgetown site was" \
|
198
|
-
"
|
197
|
+
logger.info "Success!".green, "🎉 Your new Bridgetown site was " \
|
198
|
+
"generated in #{cli_path.cyan}."
|
199
199
|
if options["skip-yarn"]
|
200
200
|
logger.info "You can now #{"cd".cyan} #{cli_path.cyan} to get started."
|
201
|
-
logger.info "You'll probably also want to #{"yarn install".cyan}" \
|
202
|
-
"
|
201
|
+
logger.info "You'll probably also want to #{"yarn install".cyan} " \
|
202
|
+
"to load in your frontend assets."
|
203
203
|
else
|
204
|
-
logger.info "You can now #{"cd".cyan} #{cli_path.cyan} and run #{bt_start.cyan}" \
|
205
|
-
"
|
204
|
+
logger.info "You can now #{"cd".cyan} #{cli_path.cyan} and run #{bt_start.cyan} " \
|
205
|
+
"to get started."
|
206
206
|
end
|
207
|
-
logger.info "Then check out our online documentation for" \
|
208
|
-
"
|
207
|
+
logger.info "Then check out our online documentation for " \
|
208
|
+
"next steps: #{DOCSURL.cyan}"
|
209
209
|
|
210
210
|
if @skipped_bundle
|
211
211
|
logger.info "Bundle install skipped.".yellow
|
@@ -13,6 +13,9 @@ module Bridgetown
|
|
13
13
|
end
|
14
14
|
|
15
15
|
desc "list", "List information about installed plugins"
|
16
|
+
option :verbose,
|
17
|
+
type: :boolean,
|
18
|
+
desc: "Print the source path of each plugin"
|
16
19
|
def list
|
17
20
|
site = Bridgetown::Site.new(configuration_with_overrides(options))
|
18
21
|
site.reset
|
@@ -32,7 +35,7 @@ module Bridgetown
|
|
32
35
|
end
|
33
36
|
end
|
34
37
|
|
35
|
-
Bridgetown.logger.info("Source Manifests:", "
|
38
|
+
Bridgetown.logger.info("Source Manifests:", "----") unless pm.class.source_manifests.empty?
|
36
39
|
|
37
40
|
pm.class.source_manifests.each do |manifest|
|
38
41
|
Bridgetown.logger.info("Origin:", (manifest.origin || "n/a").to_s.green)
|
@@ -40,20 +43,27 @@ module Bridgetown
|
|
40
43
|
Bridgetown.logger.info("Content:", (manifest.content || "n/a").to_s.cyan)
|
41
44
|
Bridgetown.logger.info("Layouts:", (manifest.layouts || "n/a").to_s.cyan)
|
42
45
|
|
43
|
-
Bridgetown.logger.info("", "
|
46
|
+
Bridgetown.logger.info("", "----")
|
44
47
|
end
|
45
48
|
|
46
49
|
unless Bridgetown.autoload? :Builder
|
47
50
|
builders = Bridgetown::Builder.descendants
|
48
51
|
Bridgetown.logger.info("Builders:", builders.length.to_s.yellow.bold)
|
49
52
|
|
50
|
-
builders.each do |builder|
|
51
|
-
name = builder
|
53
|
+
builders.sort.each do |builder|
|
54
|
+
name = plugin_name_for(builder)
|
52
55
|
name_components = name.split("::")
|
53
56
|
last_name = name_components.pop
|
54
57
|
name_components.push last_name.magenta
|
55
58
|
Bridgetown.logger.info("", name_components.join("::"))
|
59
|
+
next unless options[:verbose]
|
60
|
+
|
61
|
+
Bridgetown.logger.info(
|
62
|
+
"", "PATH: " + builder_path_for(builder)
|
63
|
+
)
|
64
|
+
Bridgetown.logger.info("")
|
56
65
|
end
|
66
|
+
Bridgetown.logger.info("", "----")
|
57
67
|
end
|
58
68
|
|
59
69
|
Bridgetown.logger.info("Converters:", site.converters.length.to_s.yellow.bold)
|
@@ -64,8 +74,16 @@ module Bridgetown
|
|
64
74
|
last_name = name_components.pop
|
65
75
|
name_components.push last_name.magenta
|
66
76
|
Bridgetown.logger.info("", name_components.join("::"))
|
77
|
+
next unless options[:verbose]
|
78
|
+
|
79
|
+
Bridgetown.logger.info(
|
80
|
+
"", "PATH: " + converter_path_for(converter)
|
81
|
+
)
|
82
|
+
Bridgetown.logger.info("")
|
67
83
|
end
|
68
84
|
|
85
|
+
Bridgetown.logger.info("", "----")
|
86
|
+
|
69
87
|
Bridgetown.logger.info("Generators:", site.generators.length.to_s.yellow.bold)
|
70
88
|
|
71
89
|
site.generators.each do |generator|
|
@@ -74,6 +92,12 @@ module Bridgetown
|
|
74
92
|
last_name = name_components.pop
|
75
93
|
name_components.push last_name.magenta
|
76
94
|
Bridgetown.logger.info("", name_components.join("::"))
|
95
|
+
next unless options[:verbose]
|
96
|
+
|
97
|
+
Bridgetown.logger.info(
|
98
|
+
"", "PATH: " + generator_path_for(generator)
|
99
|
+
)
|
100
|
+
Bridgetown.logger.info("")
|
77
101
|
end
|
78
102
|
end
|
79
103
|
|
@@ -196,11 +220,23 @@ module Bridgetown
|
|
196
220
|
protected
|
197
221
|
|
198
222
|
def plugin_name_for(plugin)
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
223
|
+
klass = plugin.is_a?(Class) ? plugin : plugin.class
|
224
|
+
klass.respond_to?(:custom_name) ? klass.custom_name : klass.name
|
225
|
+
end
|
226
|
+
|
227
|
+
def builder_path_for(plugin)
|
228
|
+
klass = plugin.is_a?(Class) ? plugin : plugin.class
|
229
|
+
klass.instance_method(:build).source_location[0]
|
230
|
+
end
|
231
|
+
|
232
|
+
def converter_path_for(plugin)
|
233
|
+
klass = plugin.is_a?(Class) ? plugin : plugin.class
|
234
|
+
klass.instance_method(:convert).source_location[0]
|
235
|
+
end
|
236
|
+
|
237
|
+
def generator_path_for(plugin)
|
238
|
+
klass = plugin.is_a?(Class) ? plugin : plugin.class
|
239
|
+
klass.instance_method(:generate).source_location[0]
|
204
240
|
end
|
205
241
|
end
|
206
242
|
end
|
@@ -4,12 +4,11 @@ module Bridgetown
|
|
4
4
|
module Commands
|
5
5
|
module Registrations
|
6
6
|
def self.registrations
|
7
|
-
@registrations
|
7
|
+
@registrations ||= []
|
8
8
|
end
|
9
9
|
|
10
10
|
def self.register(&block)
|
11
|
-
|
12
|
-
@registrations.push(block)
|
11
|
+
registrations << block
|
13
12
|
end
|
14
13
|
end
|
15
14
|
end
|
@@ -178,8 +178,8 @@ module Bridgetown
|
|
178
178
|
|
179
179
|
Process.detach(pid)
|
180
180
|
Bridgetown.logger.info "Server detached with pid '#{pid}'.", \
|
181
|
-
"Run `pkill -f bridgetown' or `kill -9 #{pid}'" \
|
182
|
-
"
|
181
|
+
"Run `pkill -f bridgetown' or `kill -9 #{pid}' " \
|
182
|
+
"to stop the server."
|
183
183
|
else
|
184
184
|
t = Thread.new { server.start }
|
185
185
|
trap("INT") { server.shutdown }
|
@@ -8,7 +8,7 @@ say "🎉 Webpack configuration updated successfully!"
|
|
8
8
|
return if Bridgetown.environment.test?
|
9
9
|
|
10
10
|
required_packages = %w(esbuild esbuild-loader css-loader@6.7.1 webpack@5.72.0 webpack-cli@4.9.2 webpack-manifest-plugin@5.0.0)
|
11
|
-
redundant_packages = %w(@babel/core @babel/plugin-proposal-class-properties @babel/plugin-proposal-decorators @babel/plugin-transform-runtime @babel/preset-env babel-loader)
|
11
|
+
redundant_packages = %w(@babel/core @babel/plugin-proposal-class-properties @babel/plugin-proposal-decorators @babel/plugin-transform-runtime @babel/preset-env babel-loader file-loader)
|
12
12
|
|
13
13
|
say "Installing required packages"
|
14
14
|
run "yarn add -D --tilde #{required_packages.join(" ")}"
|
@@ -81,22 +81,18 @@ const cssRules = {
|
|
81
81
|
|
82
82
|
const fontsRule = {
|
83
83
|
test: /\.woff2?$|\.ttf$|\.eot$/,
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
publicPath: "../fonts",
|
89
|
-
},
|
84
|
+
type: "asset/resource",
|
85
|
+
generator: {
|
86
|
+
filename: "../fonts/[name]-[hash][ext][query]"
|
87
|
+
}
|
90
88
|
}
|
91
89
|
|
92
90
|
const imagesRule = {
|
93
91
|
test: /\.png?$|\.gif$|\.jpg$|\.svg$/,
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
publicPath: "../",
|
99
|
-
},
|
92
|
+
type: "asset/resource",
|
93
|
+
generator: {
|
94
|
+
filename: "../[path][name]-[hash][ext][query]"
|
95
|
+
}
|
100
96
|
}
|
101
97
|
|
102
98
|
// Default configuration object
|
@@ -136,7 +136,7 @@ module Bridgetown
|
|
136
136
|
end
|
137
137
|
rescue StandardError => e
|
138
138
|
Bridgetown.logger.error "Component error:",
|
139
|
-
"#{self.class} encountered an error while "\
|
139
|
+
"#{self.class} encountered an error while " \
|
140
140
|
"rendering `#{self.class.path_for_errors}'"
|
141
141
|
raise e
|
142
142
|
end
|
@@ -23,7 +23,7 @@ module Bridgetown
|
|
23
23
|
output.html_safe
|
24
24
|
rescue StandardError => e
|
25
25
|
Bridgetown.logger.error "Conversion error:",
|
26
|
-
"#{converter.class} encountered an error while "\
|
26
|
+
"#{converter.class} encountered an error while " \
|
27
27
|
"converting `#{document.relative_path}'"
|
28
28
|
raise e
|
29
29
|
end
|
@@ -53,7 +53,7 @@ module Bridgetown
|
|
53
53
|
layout_output
|
54
54
|
rescue StandardError => e
|
55
55
|
Bridgetown.logger.error "Conversion error:",
|
56
|
-
"#{converter.class} encountered an error while "\
|
56
|
+
"#{converter.class} encountered an error while " \
|
57
57
|
"converting `#{document.relative_path}'"
|
58
58
|
raise e
|
59
59
|
end
|
@@ -48,7 +48,6 @@ module Bridgetown
|
|
48
48
|
"content_engine" => "resource",
|
49
49
|
"markdown" => "kramdown",
|
50
50
|
"highlighter" => "rouge",
|
51
|
-
"excerpt_separator" => "\n\n",
|
52
51
|
|
53
52
|
# Serving
|
54
53
|
"port" => "4000",
|
@@ -155,6 +154,8 @@ module Bridgetown
|
|
155
154
|
raise ArgumentError,
|
156
155
|
"No parser for '#{filename}' is available. Use a .y(a)ml or .toml file instead."
|
157
156
|
end
|
157
|
+
rescue Psych::DisallowedClass => e
|
158
|
+
raise "Unable to parse `#{File.basename(filename)}'. #{e.message}"
|
158
159
|
end
|
159
160
|
|
160
161
|
# Public: Generate list of configuration files from the override
|
@@ -208,8 +209,8 @@ module Bridgetown
|
|
208
209
|
config = Utils.deep_merge_hashes(self, new_config)
|
209
210
|
end
|
210
211
|
rescue ArgumentError => e
|
211
|
-
Bridgetown.logger.warn "WARNING:", "Error reading configuration. Using defaults" \
|
212
|
-
"
|
212
|
+
Bridgetown.logger.warn "WARNING:", "Error reading configuration. Using defaults " \
|
213
|
+
"(and options)."
|
213
214
|
warn e
|
214
215
|
end
|
215
216
|
|
@@ -10,33 +10,45 @@ create_builder "purgecss.rb" do
|
|
10
10
|
<<~RUBY
|
11
11
|
class Builders::Purgecss < SiteBuilder
|
12
12
|
def build
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
13
|
+
return if config[:watch] # don't run in "watch mode"
|
14
|
+
|
15
|
+
hook :site, :post_write do
|
16
|
+
purgecss_file = site.in_root_dir("purgecss.config.js")
|
17
|
+
|
18
|
+
unless File.exist?(purgecss_file)
|
19
|
+
config_js = <<~PURGE
|
20
|
+
module.exports = {
|
21
|
+
content: ['frontend/javascript/*.js','./output/**/*.html'],
|
22
|
+
output: "./output/_bridgetown/static"
|
23
|
+
}
|
24
|
+
PURGE
|
25
|
+
File.write(purgecss_file, config_js.strip)
|
26
|
+
end
|
27
|
+
|
28
|
+
manifest_file = File.join(site.frontend_bundling_path, "manifest.json")
|
29
|
+
|
30
|
+
if File.exist?(manifest_file)
|
31
|
+
manifest = JSON.parse(File.read(manifest_file))
|
32
|
+
|
33
|
+
if Bridgetown::Utils.frontend_bundler_type == :esbuild
|
34
|
+
css_file = manifest["styles/index.css"].split("/").last
|
35
|
+
css_path = ["output", "_bridgetown", "static", css_file].join("/")
|
36
|
+
else
|
29
37
|
css_file = manifest["main.css"].split("/").last
|
30
38
|
css_path = ["output", "_bridgetown", "static", "css", css_file].join("/")
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
39
|
+
end
|
40
|
+
|
41
|
+
Bridgetown.logger.info "PurgeCSS", "Purging \#{css_file}"
|
42
|
+
oldsize = File.stat(css_path).size / 1000
|
43
|
+
system "./node_modules/.bin/purgecss -c purgecss.config.js -css \#{css_path}"
|
44
|
+
newsize = File.stat(css_path).size / 1000
|
45
|
+
|
46
|
+
if newsize < oldsize
|
47
|
+
Bridgetown.logger.info "PurgeCSS",
|
48
|
+
"Done! File size reduced from \#{oldsize}kB to \#{newsize}kB"
|
49
|
+
else
|
50
|
+
Bridgetown.logger.info "PurgeCSS",
|
51
|
+
"Done. No apparent change in file size (\#{newsize}kB)."
|
40
52
|
end
|
41
53
|
end
|
42
54
|
end
|
@@ -4,14 +4,27 @@ say_status :shoelace, "Installing Shoelace..."
|
|
4
4
|
|
5
5
|
run "yarn add @shoelace-style/shoelace"
|
6
6
|
|
7
|
+
stylesheet_import = <<~CSS
|
8
|
+
/* Import the base Shoelace stylesheet: */
|
9
|
+
@import "@shoelace-style/shoelace/dist/themes/light.css";
|
10
|
+
|
11
|
+
CSS
|
12
|
+
|
13
|
+
if File.exist?("frontend/styles/index.css")
|
14
|
+
prepend_to_file "frontend/styles/index.css", stylesheet_import
|
15
|
+
elsif File.exist?("frontend/styles/index.scss")
|
16
|
+
prepend_to_file "frontend/styles/index.scss", stylesheet_import
|
17
|
+
else
|
18
|
+
say "\nPlease add the following lines to your CSS index file:"
|
19
|
+
say stylesheet_import
|
20
|
+
end
|
21
|
+
|
7
22
|
say 'Adding Shoelace to "frontend/javascript/index.js"...', :magenta
|
8
23
|
|
9
24
|
javascript_import do
|
10
25
|
<<~JS
|
11
|
-
// Import the base Shoelace stylesheet:
|
12
|
-
import "@shoelace-style/shoelace/dist/themes/light.css"
|
13
26
|
|
14
|
-
// Example components
|
27
|
+
// Example Shoelace components. Mix 'n' match however you like!
|
15
28
|
import "@shoelace-style/shoelace/dist/components/button/button.js"
|
16
29
|
import "@shoelace-style/shoelace/dist/components/icon/icon.js"
|
17
30
|
import "@shoelace-style/shoelace/dist/components/spinner/spinner.js"
|
@@ -45,6 +58,15 @@ else
|
|
45
58
|
'"webpack-dev": "yarn shoelace:copy-assets && webpack'
|
46
59
|
end
|
47
60
|
|
61
|
+
if File.exist?(".gitignore")
|
62
|
+
append_to_file ".gitignore" do
|
63
|
+
<<~FILES
|
64
|
+
|
65
|
+
src/shoelace-assets
|
66
|
+
FILES
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
48
70
|
say_status :shoelace, "Shoelace is now configured!"
|
49
71
|
|
50
72
|
say 'For further reading, check out "https://shoelace.style"', :blue
|
@@ -45,11 +45,13 @@ insert_into_file "Rakefile",
|
|
45
45
|
JS
|
46
46
|
end
|
47
47
|
|
48
|
-
|
49
|
-
|
48
|
+
if File.exist?(".gitignore")
|
49
|
+
append_to_file ".gitignore" do
|
50
|
+
<<~FILES
|
50
51
|
|
51
|
-
|
52
|
-
|
52
|
+
frontend/styles/jit-refresh.css
|
53
|
+
FILES
|
54
|
+
end
|
53
55
|
end
|
54
56
|
|
55
57
|
create_builder "tailwind_jit.rb" do
|
@@ -16,7 +16,7 @@ document.addEventListener("turbo:visit", () => {
|
|
16
16
|
{ opacity: 1, transform: "translateY(0px) scale(1)" },
|
17
17
|
{ opacity: 0, transform: `translateY(${movement}) scale(${scale})` }
|
18
18
|
],
|
19
|
-
{ duration: 300, easing: "cubic-bezier(0.45, 0, 0.55, 1)" }
|
19
|
+
{ duration: 300, easing: "cubic-bezier(0.45, 0, 0.55, 1)", fill: "forwards" }
|
20
20
|
);
|
21
21
|
|
22
22
|
Promise.all(main.getAnimations().map(animation => animation.finished)).then(() => {
|
@@ -79,10 +79,15 @@ module Bridgetown
|
|
79
79
|
Erubi.h(input)
|
80
80
|
end
|
81
81
|
|
82
|
-
def partial(partial_name, options
|
82
|
+
def partial(partial_name = nil, **options, &block)
|
83
|
+
partial_name = options[:template] if partial_name.nil? && options[:template]
|
83
84
|
options.merge!(options[:locals]) if options[:locals]
|
84
|
-
options[:content] =
|
85
|
+
options[:content] = capture(&block) if block
|
85
86
|
|
87
|
+
_render_partial partial_name, options
|
88
|
+
end
|
89
|
+
|
90
|
+
def _render_partial(partial_name, options)
|
86
91
|
partial_path = _partial_path(partial_name, "erb")
|
87
92
|
tmpl = site.tmp_cache["partial-tmpl:#{partial_path}"] ||= Tilt::ErubiTemplate.new(
|
88
93
|
partial_path,
|
@@ -7,10 +7,7 @@ module Bridgetown
|
|
7
7
|
class SerbeaView < ERBView
|
8
8
|
include Serbea::Helpers
|
9
9
|
|
10
|
-
def
|
11
|
-
options.merge!(options[:locals]) if options[:locals]
|
12
|
-
options[:content] = capture(&block) if block
|
13
|
-
|
10
|
+
def _render_partial(partial_name, options)
|
14
11
|
partial_path = _partial_path(partial_name, "serb")
|
15
12
|
tmpl = site.tmp_cache["partial-tmpl:#{partial_path}"] ||=
|
16
13
|
Tilt::SerbeaTemplate.new(partial_path)
|
@@ -152,8 +152,8 @@ module Bridgetown
|
|
152
152
|
return attributes[key]
|
153
153
|
end
|
154
154
|
|
155
|
-
Bridgetown.logger.warn "key `#{method_name}' not found in attributes for" \
|
156
|
-
"
|
155
|
+
Bridgetown.logger.warn "key `#{method_name}' not found in attributes for " \
|
156
|
+
"#{attributes[:id].presence || "new #{self.class}"}"
|
157
157
|
nil
|
158
158
|
end
|
159
159
|
|
@@ -33,8 +33,8 @@ module Bridgetown
|
|
33
33
|
rescue Roda::RodaError => e
|
34
34
|
if e.message.include?("sessions plugin :secret option")
|
35
35
|
raise Bridgetown::Errors::InvalidConfigurationError,
|
36
|
-
"The Roda sessions plugin can't find a valid secret. Run `bin/bridgetown secret'" \
|
37
|
-
"
|
36
|
+
"The Roda sessions plugin can't find a valid secret. Run `bin/bridgetown secret' " \
|
37
|
+
"and put the key in a ENV var you can use to configure the session in `roda_app.rb'"
|
38
38
|
end
|
39
39
|
|
40
40
|
raise e
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "rack/indifferent"
|
4
|
-
|
5
3
|
begin
|
6
4
|
# If it's in the Gemfile's :bridgetown_plugins group it's already been required, but we'll try
|
7
5
|
# again just to be on the safe side:
|
@@ -12,7 +10,16 @@ end
|
|
12
10
|
class Roda
|
13
11
|
module RodaPlugins
|
14
12
|
module BridgetownSSR
|
13
|
+
module InstanceMethods
|
14
|
+
# Helper shorthand for Bridgetown::Current.site
|
15
|
+
# @return [Bridgetown::Site]
|
16
|
+
def bridgetown_site
|
17
|
+
Bridgetown::Current.site
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
15
21
|
def self.configure(app, _opts = {}, &block)
|
22
|
+
app.include Bridgetown::Filters::URLFilters
|
16
23
|
app.opts[:bridgetown_site] =
|
17
24
|
Bridgetown::Site.start_ssr!(loaders_manager: Bridgetown::Rack.loaders_manager, &block)
|
18
25
|
end
|
@@ -21,14 +28,6 @@ class Roda
|
|
21
28
|
register_plugin :bridgetown_ssr, BridgetownSSR
|
22
29
|
|
23
30
|
module BridgetownBoot
|
24
|
-
module InstanceMethods
|
25
|
-
# Helper shorthand for Bridgetown::Current.site
|
26
|
-
# @return [Bridgetown::Site]
|
27
|
-
def bridgetown_site
|
28
|
-
Bridgetown::Current.site
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
31
|
Roda::RodaRequest.alias_method :_previous_roda_cookies, :cookies
|
33
32
|
|
34
33
|
module RequestMethods
|
@@ -53,10 +52,13 @@ end
|
|
53
52
|
module Bridgetown
|
54
53
|
module Rack
|
55
54
|
class Roda < ::Roda
|
55
|
+
SiteContext = Struct.new(:registers) # for use by Liquid-esque URL helpers
|
56
|
+
|
56
57
|
plugin :hooks
|
57
58
|
plugin :common_logger, Bridgetown::Rack::Logger.new($stdout), method: :info
|
58
59
|
plugin :json
|
59
60
|
plugin :json_parser
|
61
|
+
plugin :indifferent_params
|
60
62
|
plugin :cookies
|
61
63
|
plugin :streaming
|
62
64
|
plugin :bridgetown_boot
|
@@ -141,6 +143,7 @@ module Bridgetown
|
|
141
143
|
if self.class.opts[:bridgetown_site]
|
142
144
|
# The site had previously been initialized via the bridgetown_ssr plugin
|
143
145
|
Bridgetown::Current.site ||= self.class.opts[:bridgetown_site]
|
146
|
+
@context ||= SiteContext.new({ site: self.class.opts[:bridgetown_site] })
|
144
147
|
end
|
145
148
|
Bridgetown::Current.preloaded_configuration ||=
|
146
149
|
self.class.opts[:bridgetown_preloaded_config]
|
@@ -22,16 +22,16 @@ module Bridgetown
|
|
22
22
|
@site = page.site
|
23
23
|
end
|
24
24
|
|
25
|
-
def partial(_partial_name, _options
|
25
|
+
def partial(_partial_name = nil, **_options)
|
26
26
|
raise "Must be implemented in a subclass"
|
27
27
|
end
|
28
28
|
|
29
|
-
def render(item, options
|
29
|
+
def render(item, **options, &block)
|
30
30
|
if item.respond_to?(:render_in)
|
31
31
|
result = item.render_in(self, &block)
|
32
32
|
result&.html_safe
|
33
33
|
else
|
34
|
-
partial(item, options, &block)&.html_safe
|
34
|
+
partial(item, **options, &block)&.html_safe
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -108,7 +108,7 @@ module Bridgetown
|
|
108
108
|
self.class.mtimes[path] = mtime
|
109
109
|
|
110
110
|
FileUtils.mkdir_p(File.dirname(dest_path))
|
111
|
-
FileUtils.
|
111
|
+
FileUtils.rm_rf(dest_path)
|
112
112
|
Bridgetown.logger.debug "Saving file:", dest_path
|
113
113
|
copy_file(dest_path)
|
114
114
|
|
@@ -88,7 +88,7 @@ module Bridgetown
|
|
88
88
|
"class=\"language-#{@lang.to_s.tr("+", "-")}\"",
|
89
89
|
"data-lang=\"#{@lang}\"",
|
90
90
|
].join(" ")
|
91
|
-
"<figure class=\"highlight\"><pre><code #{code_attributes}>"\
|
91
|
+
"<figure class=\"highlight\"><pre><code #{code_attributes}>" \
|
92
92
|
"#{code.chomp}</code></pre></figure>"
|
93
93
|
end
|
94
94
|
end
|
@@ -80,7 +80,7 @@ module Bridgetown
|
|
80
80
|
next unless @post.deprecated_equality document
|
81
81
|
|
82
82
|
Bridgetown::Deprecator.deprecation_message(
|
83
|
-
"A call to "\
|
83
|
+
"A call to " \
|
84
84
|
"'{% post_url #{@post.name} %}' did not match " \
|
85
85
|
"a post using the new matching method of checking name " \
|
86
86
|
"(path-date-slug) equality. Please make sure that you " \
|
data/lib/bridgetown-core/url.rb
CHANGED
@@ -100,7 +100,7 @@ module Bridgetown
|
|
100
100
|
winner = pool.find { |key| @placeholders.key?(key) }
|
101
101
|
if winner.nil?
|
102
102
|
raise NoMethodError,
|
103
|
-
"The URL template doesn't have #{pool.join(" or ")} keys. "\
|
103
|
+
"The URL template doesn't have #{pool.join(" or ")} keys. " \
|
104
104
|
"Check your permalink template!"
|
105
105
|
end
|
106
106
|
|
@@ -99,8 +99,8 @@ module Bridgetown
|
|
99
99
|
|
100
100
|
site.process
|
101
101
|
end
|
102
|
-
Bridgetown.logger.info "Done! 🎉", "#{"Completed".bold.green} in less than" \
|
103
|
-
"
|
102
|
+
Bridgetown.logger.info "Done! 🎉", "#{"Completed".bold.green} in less than " \
|
103
|
+
"#{(Time.now - time).ceil(2)} seconds."
|
104
104
|
rescue StandardError => e
|
105
105
|
Bridgetown::Errors.print_build_error(e, trace: options[:trace])
|
106
106
|
end
|
@@ -24,6 +24,10 @@ gem "bridgetown", "~> <%= Bridgetown::VERSION %>"
|
|
24
24
|
# Uncomment to add file-based dynamic routing to your project:
|
25
25
|
# gem "bridgetown-routes", "~> <%= Bridgetown::VERSION %>", group: :bridgetown_plugins
|
26
26
|
|
27
|
+
# Uncomment to use the Inspectors API to manipulate the output
|
28
|
+
# of your HTML or XML resources:
|
29
|
+
# gem "nokogiri", "~> 1.13"
|
30
|
+
|
27
31
|
# Puma is a Rack-compatible server used by Bridgetown
|
28
32
|
# (you can optionally limit this to the "development" group)
|
29
33
|
gem "puma", "~> 5.6"
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<!doctype html>
|
2
2
|
<html lang="{{ site.locale }}">
|
3
3
|
<head>
|
4
|
-
{% render "head", metadata: site.metadata, title:
|
4
|
+
{% render "head", metadata: site.metadata, title: resource.data.title %}
|
5
5
|
</head>
|
6
6
|
<body class="{{ resource.data.layout }} {{ resource.data.page_class }}">
|
7
7
|
{% render "navbar", metadata: site.metadata, resource: resource %}
|
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: 1.1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bridgetown Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -218,20 +218,6 @@ dependencies:
|
|
218
218
|
- - "~>"
|
219
219
|
- !ruby/object:Gem::Version
|
220
220
|
version: '3.0'
|
221
|
-
- !ruby/object:Gem::Dependency
|
222
|
-
name: rack-indifferent
|
223
|
-
requirement: !ruby/object:Gem::Requirement
|
224
|
-
requirements:
|
225
|
-
- - ">="
|
226
|
-
- !ruby/object:Gem::Version
|
227
|
-
version: 1.2.0
|
228
|
-
type: :runtime
|
229
|
-
prerelease: false
|
230
|
-
version_requirements: !ruby/object:Gem::Requirement
|
231
|
-
requirements:
|
232
|
-
- - ">="
|
233
|
-
- !ruby/object:Gem::Version
|
234
|
-
version: 1.2.0
|
235
221
|
- !ruby/object:Gem::Dependency
|
236
222
|
name: rake
|
237
223
|
requirement: !ruby/object:Gem::Requirement
|
@@ -622,9 +608,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
622
608
|
version: 2.7.0
|
623
609
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
624
610
|
requirements:
|
625
|
-
- - "
|
611
|
+
- - ">="
|
626
612
|
- !ruby/object:Gem::Version
|
627
|
-
version:
|
613
|
+
version: '0'
|
628
614
|
requirements: []
|
629
615
|
rubygems_version: 3.1.4
|
630
616
|
signing_key:
|