bridgetown-core 0.21.0.beta3 → 0.21.0.beta4
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/commands/new.rb +4 -4
- data/lib/bridgetown-core/commands/webpack.rb +75 -0
- data/lib/bridgetown-core/commands/webpack/enable-postcss.rb +12 -0
- data/lib/bridgetown-core/commands/webpack/setup.rb +4 -0
- data/lib/bridgetown-core/commands/webpack/update.rb +3 -0
- data/lib/bridgetown-core/commands/webpack/webpack.config.js +18 -0
- data/lib/{site_template/webpack.config.js.erb → bridgetown-core/commands/webpack/webpack.defaults.js.erb} +22 -10
- data/lib/bridgetown-core/component.rb +36 -31
- data/lib/bridgetown-core/concerns/layout_placeable.rb +1 -1
- data/lib/bridgetown-core/configuration.rb +10 -3
- data/lib/bridgetown-core/configurations/bt-postcss.rb +5 -3
- data/lib/bridgetown-core/configurations/tailwindcss.rb +5 -3
- data/lib/bridgetown-core/generators/prototype_generator.rb +25 -4
- data/lib/bridgetown-core/layout.rb +27 -10
- data/lib/bridgetown-core/readers/layout_reader.rb +1 -1
- data/lib/bridgetown-core/resource/base.rb +16 -0
- data/lib/bridgetown-core/version.rb +1 -1
- data/lib/bridgetown-core/watcher.rb +1 -0
- data/lib/site_template/config/.keep +0 -0
- data/lib/site_template/package.json.erb +2 -2
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2082873c6388655e983a22a2629e5d25ac322095c5bcc1dbbd6a4d7ee9b28957
|
4
|
+
data.tar.gz: b6952e9d9b9cee1470da8d3dd5e170b1ec331a3e6fe7ce41128943ff0db6f7a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25d4e5d41be9a9b88e46d402726253fe400cd2d53d133e75337204ae3daafd7b41e275d3dbafa7bebf7d70f13de641371b3142251e746f4a2ba70238f9657d26
|
7
|
+
data.tar.gz: d51d1a5c5d6e9a714fac3f24b722b91e8a5fc9f1d42ab750060daa8f34999d460e55ac237f2a534e370795f978209c8249a7750d76f986e98aae84938293064e
|
@@ -86,10 +86,10 @@ module Bridgetown
|
|
86
86
|
)
|
87
87
|
template("Gemfile.erb", "Gemfile")
|
88
88
|
template("package.json.erb", "package.json")
|
89
|
-
template("webpack.config.js.erb", "webpack.config.js")
|
90
89
|
template("frontend/javascript/index.js.erb", "frontend/javascript/index.js")
|
91
90
|
|
92
91
|
options["use-postcss"] ? configure_postcss : configure_sass
|
92
|
+
invoke(Webpack, ["setup"], {})
|
93
93
|
end
|
94
94
|
|
95
95
|
def configure_sass
|
@@ -140,7 +140,7 @@ module Bridgetown
|
|
140
140
|
# rubocop:enable Metrics/PerceivedComplexity
|
141
141
|
|
142
142
|
def bundle_install(path)
|
143
|
-
unless Bridgetown.environment
|
143
|
+
unless Bridgetown.environment.test?
|
144
144
|
require "bundler"
|
145
145
|
Bridgetown.with_unbundled_env do
|
146
146
|
inside(path) do
|
@@ -156,7 +156,7 @@ module Bridgetown
|
|
156
156
|
end
|
157
157
|
|
158
158
|
def git_init(path)
|
159
|
-
unless Bridgetown.environment
|
159
|
+
unless Bridgetown.environment.test?
|
160
160
|
inside(path) do
|
161
161
|
initialize_new_repo
|
162
162
|
end
|
@@ -166,7 +166,7 @@ module Bridgetown
|
|
166
166
|
end
|
167
167
|
|
168
168
|
def yarn_install(path)
|
169
|
-
unless Bridgetown.environment
|
169
|
+
unless Bridgetown.environment.test?
|
170
170
|
inside(path) do
|
171
171
|
run "yarn install", abort_on_failure: true
|
172
172
|
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bridgetown
|
4
|
+
module Commands
|
5
|
+
class Webpack < Thor::Group
|
6
|
+
include Thor::Actions
|
7
|
+
extend Summarizable
|
8
|
+
|
9
|
+
Registrations.register do
|
10
|
+
register(Webpack, "webpack", "webpack ACTION", Webpack.summary)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.banner
|
14
|
+
"bridgetown webpack ACTION"
|
15
|
+
end
|
16
|
+
summary "Perform actions on the bridgetown webpack configuration"
|
17
|
+
|
18
|
+
def self.exit_on_failure?
|
19
|
+
true
|
20
|
+
end
|
21
|
+
|
22
|
+
def webpack
|
23
|
+
@logger = Bridgetown.logger
|
24
|
+
return show_actions if args.empty?
|
25
|
+
|
26
|
+
action = args.first
|
27
|
+
if supported_actions.include?(action)
|
28
|
+
perform action
|
29
|
+
else
|
30
|
+
@logger.error "Error:".red, "🚨 Please enter a valid action."
|
31
|
+
say "\n"
|
32
|
+
show_actions
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.source_root
|
37
|
+
File.expand_path("./webpack", __dir__)
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.destination_root
|
41
|
+
config.root_dir
|
42
|
+
end
|
43
|
+
|
44
|
+
def config
|
45
|
+
@config ||= Bridgetown.configuration({ root_dir: Dir.pwd })
|
46
|
+
end
|
47
|
+
|
48
|
+
protected
|
49
|
+
|
50
|
+
def perform(action)
|
51
|
+
automation = find_in_source_paths("#{action}.rb")
|
52
|
+
inside(New.created_site_dir || Dir.pwd) do
|
53
|
+
apply automation, verbose: false
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def show_actions
|
58
|
+
say "Available actions:\n".bold
|
59
|
+
|
60
|
+
longest_action = supported_actions.keys.max_by(&:size).size
|
61
|
+
supported_actions.each do |action, description|
|
62
|
+
say action.ljust(longest_action).to_s.bold.blue + "\t" + "# #{description}"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def supported_actions
|
67
|
+
{
|
68
|
+
setup: "Sets up a webpack integration with Bridgetown in your project",
|
69
|
+
update: "Updates the Bridgetown webpack defaults to the latest available version",
|
70
|
+
"enable-postcss": "Configures PostCSS in your project",
|
71
|
+
}.with_indifferent_access
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
default_postcss_config = File.expand_path("../../../site_template/postcss.config.js.erb", __dir__)
|
4
|
+
|
5
|
+
template default_postcss_config, "postcss.config.js"
|
6
|
+
template "webpack.defaults.js.erb", "config/webpack.defaults.js", force: true
|
7
|
+
|
8
|
+
unless Bridgetown.environment.test?
|
9
|
+
packages = %w(postcss@8.3.0 postcss-loader@4.3.0 postcss-flexbugs-fixes postcss-preset-env)
|
10
|
+
run "yarn add -D #{packages.join(" ")}"
|
11
|
+
run "yarn remove sass sass-loader"
|
12
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
const config = require("./config/webpack.defaults.js")
|
2
|
+
|
3
|
+
// Add any overrides to the default webpack config here:
|
4
|
+
|
5
|
+
// Eg:
|
6
|
+
//
|
7
|
+
// ```
|
8
|
+
// const path = require("path")
|
9
|
+
// config.resolve.modules.push(path.resolve(__dirname, 'frontend', 'components'))
|
10
|
+
// config.resolve.alias.frontendComponents = path.resolve(__dirname, 'frontend', 'components')
|
11
|
+
// ```
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
////////////////////////////////////////////////////////
|
17
|
+
|
18
|
+
module.exports = config
|
@@ -1,10 +1,21 @@
|
|
1
|
+
// This file is created and managed by Bridgetown.
|
2
|
+
// Instead of editing this file, add your overrides to `webpack.config.js`
|
3
|
+
//
|
4
|
+
// To update this file to the latest version provided by Bridgetown,
|
5
|
+
// run `bridgetown webpack update`. Any changes to this file will be overwritten
|
6
|
+
// when an update is applied hence we strongly recommend adding overrides to
|
7
|
+
// `webpack.config.js` instead of editing this file.
|
8
|
+
//
|
9
|
+
// Shipped with Bridgetown v<%= Bridgetown::VERSION %>
|
10
|
+
|
1
11
|
const path = require("path");
|
12
|
+
const rootDir = path.resolve(__dirname, "..")
|
2
13
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
3
14
|
const ManifestPlugin = require("webpack-manifest-plugin");
|
4
15
|
|
5
16
|
module.exports = {
|
6
17
|
entry: {
|
7
|
-
main: "
|
18
|
+
main: path.resolve(rootDir, "frontend", "javascript", "index.js")
|
8
19
|
},
|
9
20
|
devtool: "source-map",
|
10
21
|
// Set some or all of these to true if you want more verbose logging:
|
@@ -15,18 +26,18 @@ module.exports = {
|
|
15
26
|
children: false,
|
16
27
|
},
|
17
28
|
output: {
|
18
|
-
path: path.resolve(
|
29
|
+
path: path.resolve(rootDir, "output", "_bridgetown", "static", "js"),
|
19
30
|
filename: "[name].[contenthash].js",
|
20
31
|
},
|
21
32
|
resolve: {
|
22
33
|
extensions: [".js", ".jsx"],
|
23
34
|
modules: [
|
24
|
-
path.resolve(
|
25
|
-
path.resolve(
|
26
|
-
path.resolve('
|
35
|
+
path.resolve(rootDir, 'frontend', 'javascript'),
|
36
|
+
path.resolve(rootDir, 'frontend', 'styles'),
|
37
|
+
path.resolve(rootDir, 'node_modules')
|
27
38
|
],
|
28
39
|
alias: {
|
29
|
-
bridgetownComponents: path.resolve(
|
40
|
+
bridgetownComponents: path.resolve(rootDir, "src", "_components")
|
30
41
|
}
|
31
42
|
},
|
32
43
|
plugins: [
|
@@ -34,7 +45,7 @@ module.exports = {
|
|
34
45
|
filename: "../css/[name].[contenthash].css",
|
35
46
|
}),
|
36
47
|
new ManifestPlugin({
|
37
|
-
fileName: path.resolve(
|
48
|
+
fileName: path.resolve(rootDir, ".bridgetown-webpack", "manifest.json"),
|
38
49
|
}),
|
39
50
|
],
|
40
51
|
module: {
|
@@ -54,11 +65,12 @@ module.exports = {
|
|
54
65
|
helpers: false,
|
55
66
|
},
|
56
67
|
],
|
68
|
+
["@babel/plugin-proposal-private-methods", { "loose": true }],
|
57
69
|
],
|
58
70
|
},
|
59
71
|
},
|
60
72
|
},
|
61
|
-
<% if
|
73
|
+
<% if self.config.uses_postcss? %>
|
62
74
|
{
|
63
75
|
test: /\.(s[ac]|c)ss$/,
|
64
76
|
use: [
|
@@ -91,7 +103,7 @@ module.exports = {
|
|
91
103
|
sassOptions: {
|
92
104
|
fiber: false,
|
93
105
|
includePaths: [
|
94
|
-
path.resolve(
|
106
|
+
path.resolve(rootDir, "src/_components")
|
95
107
|
],
|
96
108
|
},
|
97
109
|
},
|
@@ -119,4 +131,4 @@ module.exports = {
|
|
119
131
|
},
|
120
132
|
],
|
121
133
|
},
|
122
|
-
};
|
134
|
+
};
|
@@ -30,24 +30,24 @@ module Bridgetown
|
|
30
30
|
#
|
31
31
|
# @param ext [String] erb, slim, etc.
|
32
32
|
def renderer_for_ext(ext, &block)
|
33
|
-
case ext
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
33
|
+
@_tmpl ||= case ext
|
34
|
+
when "erb"
|
35
|
+
include ERBCapture
|
36
|
+
Tilt::ErubiTemplate.new(component_template_path,
|
37
|
+
outvar: "@_erbout",
|
38
|
+
bufval: "Bridgetown::OutputBuffer.new",
|
39
|
+
engine_class: Bridgetown::ERBEngine,
|
40
|
+
&block)
|
41
|
+
when "serb" # requires serbea
|
42
|
+
include Serbea::Helpers
|
43
|
+
Tilt::SerbeaTemplate.new(component_template_path, &block)
|
44
|
+
when "slim" # requires bridgetown-slim
|
45
|
+
Slim::Template.new(component_template_path, &block)
|
46
|
+
when "haml" # requires bridgetown-haml
|
47
|
+
Tilt::HamlTemplate.new(component_template_path, &block)
|
48
|
+
else
|
49
|
+
raise NameError
|
50
|
+
end
|
51
51
|
rescue NameError, LoadError
|
52
52
|
raise "No component rendering engine could be found for .#{ext} templates"
|
53
53
|
end
|
@@ -56,26 +56,32 @@ module Bridgetown
|
|
56
56
|
#
|
57
57
|
# @return [String]
|
58
58
|
def component_template_path
|
59
|
-
|
60
|
-
File.
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
59
|
+
@_tmpl_path ||= begin
|
60
|
+
stripped_path = File.join(
|
61
|
+
File.dirname(source_location),
|
62
|
+
File.basename(source_location, ".*")
|
63
|
+
)
|
64
|
+
supported_template_extensions.each do |ext|
|
65
|
+
test_path = "#{stripped_path}.#{ext}"
|
66
|
+
break test_path if File.exist?(test_path)
|
67
|
+
|
68
|
+
test_path = "#{stripped_path}.html.#{ext}"
|
69
|
+
break test_path if File.exist?(test_path)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
unless @_tmpl_path.is_a?(String)
|
74
|
+
raise "#{name}: no matching template could be found in #{File.dirname(source_location)}"
|
69
75
|
end
|
70
76
|
|
71
|
-
|
77
|
+
@_tmpl_path
|
72
78
|
end
|
73
79
|
|
74
80
|
# Read the template file.
|
75
81
|
#
|
76
82
|
# @return [String]
|
77
83
|
def component_template_content
|
78
|
-
File.read(component_template_path)
|
84
|
+
@_tmpl_content ||= File.read(component_template_path)
|
79
85
|
end
|
80
86
|
|
81
87
|
# A list of extensions supported by the renderer
|
@@ -154,7 +160,6 @@ module Bridgetown
|
|
154
160
|
end
|
155
161
|
|
156
162
|
def _renderer
|
157
|
-
# TODO: figure out a way to compile templates for increased performance
|
158
163
|
@_renderer ||= begin
|
159
164
|
ext = File.extname(self.class.component_template_path).delete_prefix(".")
|
160
165
|
self.class.renderer_for_ext(ext) { self.class.component_template_content }
|
@@ -118,7 +118,7 @@ module Bridgetown
|
|
118
118
|
# override - the command-line options hash
|
119
119
|
#
|
120
120
|
# Returns the path to the Bridgetown root directory
|
121
|
-
def root_dir(override)
|
121
|
+
def root_dir(override = "")
|
122
122
|
get_config_value_with_override("root_dir", override)
|
123
123
|
end
|
124
124
|
|
@@ -127,7 +127,7 @@ module Bridgetown
|
|
127
127
|
# override - the command-line options hash
|
128
128
|
#
|
129
129
|
# Returns the path to the Bridgetown source directory
|
130
|
-
def source(override)
|
130
|
+
def source(override = "")
|
131
131
|
get_config_value_with_override("source", override)
|
132
132
|
end
|
133
133
|
|
@@ -226,7 +226,7 @@ module Bridgetown
|
|
226
226
|
raise ArgumentError, "Configuration file: (INVALID) #{file}".yellow
|
227
227
|
end
|
228
228
|
|
229
|
-
Bridgetown.logger.
|
229
|
+
Bridgetown.logger.debug "Configuration file:", file
|
230
230
|
next_config
|
231
231
|
rescue SystemCallError
|
232
232
|
if @default_config_file ||= nil
|
@@ -340,5 +340,12 @@ module Bridgetown
|
|
340
340
|
|
341
341
|
self
|
342
342
|
end
|
343
|
+
|
344
|
+
# Whether or not PostCSS is being used to process stylesheets.
|
345
|
+
#
|
346
|
+
# @return [Boolean] true if `postcss.config.js` exists, false if not
|
347
|
+
def uses_postcss?
|
348
|
+
File.exist?(Bridgetown.sanitized_path(root_dir, "postcss.config.js"))
|
349
|
+
end
|
343
350
|
end
|
344
351
|
end
|
@@ -8,17 +8,19 @@ unless File.exist?("postcss.config.js")
|
|
8
8
|
error_message = "#{"postcss.config.js".bold} not found. Please configure postcss in your project."
|
9
9
|
|
10
10
|
@logger.error "\nError:".red, "🚨 #{error_message}"
|
11
|
-
@logger.info "\
|
11
|
+
@logger.info "\nRun #{"bridgetown webpack enable-postcss".bold.blue} to set it up.\n"
|
12
12
|
|
13
13
|
return
|
14
14
|
end
|
15
15
|
|
16
|
+
confirm = ask "This configuration will ovewrite your existing #{"postcss.config.js".bold.white}. Would you like to continue? [Yn]"
|
17
|
+
return unless confirm.casecmp?("Y")
|
18
|
+
|
16
19
|
plugins = %w(postcss-easy-import postcss-mixins postcss-color-function cssnano)
|
17
20
|
|
18
21
|
say "Adding the following PostCSS plugins: #{plugins.join(' | ')}", :green
|
19
22
|
run "yarn add -D #{plugins.join(' ')}"
|
20
23
|
|
21
|
-
|
22
|
-
copy_file "#{TEMPLATE_PATH}/postcss.config.js", "postcss.config.js"
|
24
|
+
copy_file "#{TEMPLATE_PATH}/postcss.config.js", "postcss.config.js", force: true
|
23
25
|
|
24
26
|
# rubocop:enable all
|
@@ -8,16 +8,18 @@ unless File.exist?("postcss.config.js")
|
|
8
8
|
error_message = "#{"postcss.config.js".bold} not found. Please configure postcss in your project."
|
9
9
|
|
10
10
|
@logger.error "\nError:".red, "🚨 #{error_message}"
|
11
|
-
@logger.info "\
|
11
|
+
@logger.info "\nRun #{"bridgetown webpack enable-postcss".bold.blue} to set it up.\n"
|
12
12
|
|
13
13
|
return
|
14
14
|
end
|
15
15
|
|
16
|
+
confirm = ask "This configuration will ovewrite your existing #{"postcss.config.js".bold.white}. Would you like to continue? [Yn]"
|
17
|
+
return unless confirm.casecmp?("Y")
|
18
|
+
|
16
19
|
run "yarn add -D tailwindcss"
|
17
20
|
run "npx tailwindcss init"
|
18
21
|
|
19
|
-
|
20
|
-
copy_file "#{TEMPLATE_PATH}/postcss.config.js", "postcss.config.js"
|
22
|
+
copy_file "#{TEMPLATE_PATH}/postcss.config.js", "postcss.config.js", force: true
|
21
23
|
|
22
24
|
prepend_to_file "frontend/styles/index.css",
|
23
25
|
File.read("#{TEMPLATE_PATH}/css_imports.css")
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Handles
|
3
|
+
# Handles Generated Pages
|
4
4
|
Bridgetown::Hooks.register :pages, :post_init, reloadable: false do |page|
|
5
5
|
if page.class != Bridgetown::PrototypePage && page.data["prototype"].is_a?(Hash)
|
6
6
|
Bridgetown::PrototypeGenerator.add_matching_template(page)
|
@@ -14,6 +14,11 @@ Bridgetown::Hooks.register :resources, :post_read, reloadable: false do |resourc
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
+
# Ensure sites clear out templates before rebuild
|
18
|
+
Bridgetown::Hooks.register :site, :after_reset, reloadable: false do |_site|
|
19
|
+
Bridgetown::PrototypeGenerator.matching_templates.clear
|
20
|
+
end
|
21
|
+
|
17
22
|
module Bridgetown
|
18
23
|
class PrototypeGenerator < Generator
|
19
24
|
priority :low
|
@@ -21,9 +26,9 @@ module Bridgetown
|
|
21
26
|
# @return [Bridgetown::Site]
|
22
27
|
attr_reader :site
|
23
28
|
|
24
|
-
# @return [
|
29
|
+
# @return [Set<Bridgetown::Page, Bridgetown::Resource::Base>]
|
25
30
|
def self.matching_templates
|
26
|
-
@matching_templates ||=
|
31
|
+
@matching_templates ||= Set.new
|
27
32
|
end
|
28
33
|
|
29
34
|
def self.add_matching_template(template)
|
@@ -41,6 +46,8 @@ module Bridgetown
|
|
41
46
|
end
|
42
47
|
|
43
48
|
if prototype_pages.length.positive?
|
49
|
+
ensure_pagination_enabled
|
50
|
+
|
44
51
|
page_list.reject! do |page|
|
45
52
|
prototype_pages.include? page
|
46
53
|
end
|
@@ -56,6 +63,15 @@ module Bridgetown
|
|
56
63
|
end
|
57
64
|
end
|
58
65
|
|
66
|
+
def ensure_pagination_enabled
|
67
|
+
unless @site.config.dig(:pagination, :enabled)
|
68
|
+
Bridgetown.logger.warn(
|
69
|
+
"Pagination:",
|
70
|
+
"Must be enabled for prototype pages to contain matches"
|
71
|
+
)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
59
75
|
# Check incoming prototype configuration and normalize options.
|
60
76
|
#
|
61
77
|
# @param prototype_page [Bridgetown::Page, Bridgetown::Resource::Base]
|
@@ -70,7 +86,12 @@ module Bridgetown
|
|
70
86
|
@configured_collection = prototype_page.data["prototype"]["collection"]
|
71
87
|
end
|
72
88
|
|
73
|
-
|
89
|
+
unless site.collections[@configured_collection]
|
90
|
+
Bridgetown.logger.warn(
|
91
|
+
"No collection specified for prototype page #{prototype_page.relative_path}"
|
92
|
+
)
|
93
|
+
return nil
|
94
|
+
end
|
74
95
|
|
75
96
|
# Categories and Tags are unique in that singular and plural front matter
|
76
97
|
# can be present for each
|
@@ -39,12 +39,22 @@ module Bridgetown
|
|
39
39
|
# Gets/Sets the document output (for layout-compatible converters)
|
40
40
|
attr_accessor :current_document_output
|
41
41
|
|
42
|
+
# Determines the label a layout should use based on its filename
|
43
|
+
#
|
44
|
+
# @param file [String]
|
45
|
+
# @return [String]
|
46
|
+
def self.label_for_file(file)
|
47
|
+
# TODO: refactor this so multi-extension layout filenames don't leak
|
48
|
+
# middle extensions into layout label
|
49
|
+
file.split(".")[0..-2].join(".")
|
50
|
+
end
|
51
|
+
|
42
52
|
# Initialize a new Layout.
|
43
53
|
#
|
44
|
-
# site
|
45
|
-
# base
|
46
|
-
# name
|
47
|
-
# from_plugin
|
54
|
+
# @param site [Bridgetown::Site]
|
55
|
+
# @param base [String] The path to the source.
|
56
|
+
# @param name [String] The filename of the layout file.
|
57
|
+
# @param from_plugin [Boolean] if the layout comes from a Gem-based plugin folder.
|
48
58
|
def initialize(site, base, name, from_plugin: false)
|
49
59
|
@site = site
|
50
60
|
@base = base
|
@@ -83,17 +93,24 @@ module Bridgetown
|
|
83
93
|
end
|
84
94
|
end
|
85
95
|
|
86
|
-
# The
|
87
|
-
#
|
96
|
+
# The label of the layout (should match what would used in front matter
|
97
|
+
# references).
|
88
98
|
#
|
89
|
-
#
|
99
|
+
# @return [String]
|
100
|
+
def label
|
101
|
+
@label ||= self.class.label_for_file(name)
|
102
|
+
end
|
103
|
+
|
104
|
+
# The inspect string for this layout. Includes the relative path.
|
105
|
+
#
|
106
|
+
# @return [String]
|
90
107
|
def inspect
|
91
|
-
"#<#{self.class} #{
|
108
|
+
"#<#{self.class} #{relative_path}>"
|
92
109
|
end
|
93
110
|
|
94
|
-
# Provide this Layout's data
|
111
|
+
# Provide this Layout's data for use by Liquid.
|
95
112
|
#
|
96
|
-
#
|
113
|
+
# @return [HashWithDotAccess::Hash]
|
97
114
|
def to_liquid
|
98
115
|
data
|
99
116
|
end
|
@@ -42,6 +42,22 @@ module Bridgetown
|
|
42
42
|
model.collection
|
43
43
|
end
|
44
44
|
|
45
|
+
# Layout associated with this resource
|
46
|
+
# This will output a warning if the layout can't be found.
|
47
|
+
#
|
48
|
+
# @return [Bridgetown::Layout]
|
49
|
+
def layout
|
50
|
+
return @layout if @layout
|
51
|
+
return if no_layout?
|
52
|
+
|
53
|
+
@layout = site.layouts[data.layout].tap do |layout|
|
54
|
+
unless layout
|
55
|
+
Bridgetown.logger.warn "Resource:", "Layout '#{data.layout}' " \
|
56
|
+
"requested via #{relative_path} does not exist."
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
45
61
|
# The relative path of source file or file-like origin
|
46
62
|
#
|
47
63
|
# @return [Pathname]
|
@@ -127,6 +127,7 @@ module Bridgetown
|
|
127
127
|
|
128
128
|
def process(site, time, options)
|
129
129
|
begin
|
130
|
+
I18n.reload! # make sure any locale files get read again
|
130
131
|
Bridgetown::Hooks.trigger :site, :pre_reload, site
|
131
132
|
Bridgetown::Hooks.clear_reloadable_hooks
|
132
133
|
site.plugin_manager.reload_plugin_files
|
File without changes
|
@@ -25,9 +25,9 @@
|
|
25
25
|
"file-loader": "^6.2.0",
|
26
26
|
"mini-css-extract-plugin": "^1.3.1",
|
27
27
|
<% if options["use-postcss"] %>
|
28
|
-
"postcss": "^8.
|
28
|
+
"postcss": "^8.3.0",
|
29
29
|
"postcss-flexbugs-fixes": "^4.1.0",
|
30
|
-
"postcss-loader": "^4.
|
30
|
+
"postcss-loader": "^4.3.0",
|
31
31
|
"postcss-preset-env": "^6.7.0",
|
32
32
|
<% else %>
|
33
33
|
"sass": "^1.32.8",
|
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.0.
|
4
|
+
version: 0.21.0.beta4
|
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-05-
|
11
|
+
date: 2021-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -323,6 +323,12 @@ files:
|
|
323
323
|
- lib/bridgetown-core/commands/registrations.rb
|
324
324
|
- lib/bridgetown-core/commands/serve.rb
|
325
325
|
- lib/bridgetown-core/commands/serve/servlet.rb
|
326
|
+
- lib/bridgetown-core/commands/webpack.rb
|
327
|
+
- lib/bridgetown-core/commands/webpack/enable-postcss.rb
|
328
|
+
- lib/bridgetown-core/commands/webpack/setup.rb
|
329
|
+
- lib/bridgetown-core/commands/webpack/update.rb
|
330
|
+
- lib/bridgetown-core/commands/webpack/webpack.config.js
|
331
|
+
- lib/bridgetown-core/commands/webpack/webpack.defaults.js.erb
|
326
332
|
- lib/bridgetown-core/component.rb
|
327
333
|
- lib/bridgetown-core/concerns/data_accessible.rb
|
328
334
|
- lib/bridgetown-core/concerns/front_matter_importer.rb
|
@@ -450,6 +456,7 @@ files:
|
|
450
456
|
- lib/site_template/Gemfile.erb
|
451
457
|
- lib/site_template/README.md
|
452
458
|
- lib/site_template/bridgetown.config.yml
|
459
|
+
- lib/site_template/config/.keep
|
453
460
|
- lib/site_template/frontend/javascript/index.js.erb
|
454
461
|
- lib/site_template/frontend/styles/index.css
|
455
462
|
- lib/site_template/frontend/styles/index.scss
|
@@ -474,7 +481,6 @@ files:
|
|
474
481
|
- lib/site_template/src/posts.md
|
475
482
|
- lib/site_template/start.js
|
476
483
|
- lib/site_template/sync.js
|
477
|
-
- lib/site_template/webpack.config.js.erb
|
478
484
|
homepage: https://www.bridgetownrb.com
|
479
485
|
licenses:
|
480
486
|
- MIT
|