bridgetown-core 1.0.0.alpha6 → 1.0.0.alpha10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -0
- data/bin/bridgetown +8 -1
- data/bridgetown-core.gemspec +3 -3
- data/lib/bridgetown-core/cache.rb +1 -1
- data/lib/bridgetown-core/collection.rb +1 -1
- data/lib/bridgetown-core/commands/concerns/configuration_overridable.rb +7 -0
- data/lib/bridgetown-core/commands/configure.rb +7 -0
- data/lib/bridgetown-core/commands/console.rb +38 -12
- data/lib/bridgetown-core/commands/doctor.rb +8 -5
- data/lib/bridgetown-core/commands/new.rb +1 -0
- data/lib/bridgetown-core/commands/plugins.rb +1 -1
- data/lib/bridgetown-core/component.rb +2 -2
- data/lib/bridgetown-core/concerns/front_matter_importer.rb +1 -1
- data/lib/bridgetown-core/concerns/site/configurable.rb +6 -3
- data/lib/bridgetown-core/concerns/site/extensible.rb +2 -1
- data/lib/bridgetown-core/concerns/site/ssr.rb +38 -16
- data/lib/bridgetown-core/configuration.rb +77 -46
- data/lib/bridgetown-core/configurations/bt-postcss.rb +1 -3
- data/lib/bridgetown-core/configurations/cypress/cypress.json +4 -0
- data/lib/bridgetown-core/configurations/cypress/cypress_dir/fixtures/example.json +5 -0
- data/lib/bridgetown-core/configurations/cypress/cypress_dir/integration/navbar.spec.js +17 -0
- data/lib/bridgetown-core/configurations/cypress/cypress_dir/plugins/index.js +21 -0
- data/lib/bridgetown-core/configurations/cypress/cypress_dir/support/commands.js +25 -0
- data/lib/bridgetown-core/configurations/cypress/cypress_dir/support/index.js +20 -0
- data/lib/bridgetown-core/configurations/cypress/cypress_tasks +33 -0
- data/lib/bridgetown-core/configurations/cypress.rb +13 -0
- data/lib/bridgetown-core/configurations/minitesting.rb +19 -15
- data/lib/bridgetown-core/configurations/netlify.rb +2 -4
- data/lib/bridgetown-core/configurations/purgecss.rb +2 -2
- data/lib/bridgetown-core/configurations/render/render.yaml.erb +26 -0
- data/lib/bridgetown-core/configurations/render.rb +6 -0
- data/lib/bridgetown-core/configurations/tailwindcss.rb +3 -5
- data/lib/bridgetown-core/converters/erb_templates.rb +1 -1
- data/lib/bridgetown-core/converters/markdown/kramdown_parser.rb +1 -1
- data/lib/bridgetown-core/converters/serbea_templates.rb +71 -0
- data/lib/bridgetown-core/core_ext/psych.rb +1 -5
- data/lib/bridgetown-core/frontmatter_defaults.rb +2 -2
- data/lib/bridgetown-core/liquid_renderer/file_system.rb +1 -3
- data/lib/bridgetown-core/liquid_renderer.rb +1 -1
- data/lib/bridgetown-core/model/base.rb +23 -26
- data/lib/bridgetown-core/model/builder_origin.rb +8 -6
- data/lib/bridgetown-core/model/origin.rb +10 -1
- data/lib/bridgetown-core/model/plugin_origin.rb +1 -1
- data/lib/bridgetown-core/plugin_manager.rb +9 -36
- data/lib/bridgetown-core/rack/boot.rb +46 -23
- data/lib/bridgetown-core/rack/roda.rb +2 -1
- data/lib/bridgetown-core/rack/routes.rb +2 -2
- data/lib/bridgetown-core/readers/layout_reader.rb +1 -1
- data/lib/bridgetown-core/readers/plugin_content_reader.rb +1 -1
- data/lib/bridgetown-core/renderer.rb +2 -2
- data/lib/bridgetown-core/resource/base.rb +3 -3
- data/lib/bridgetown-core/resource/relations.rb +1 -1
- data/lib/bridgetown-core/resource/taxonomy_term.rb +2 -2
- data/lib/bridgetown-core/resource/taxonomy_type.rb +2 -2
- data/lib/bridgetown-core/ruby_template_view.rb +2 -2
- data/lib/bridgetown-core/site.rb +15 -5
- data/lib/bridgetown-core/utils/loaders_manager.rb +83 -0
- data/lib/bridgetown-core/utils.rb +13 -14
- data/lib/bridgetown-core/version.rb +1 -1
- data/lib/bridgetown-core/watcher.rb +16 -7
- data/lib/bridgetown-core/yaml_parser.rb +1 -5
- data/lib/bridgetown-core.rb +0 -1
- data/lib/site_template/README.md +1 -1
- data/lib/site_template/Rakefile +3 -3
- metadata +45 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b529c24ff76bbed44607ecbef4d5dd66414bded0cb8d1640cfb6945d1ae7e9c
|
4
|
+
data.tar.gz: 2522b693b676608de3546183310970d7def3e05c6bbdf5561699fc434e4b3f6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a628d623d424930d62deebff57273a72899b6399fc6ce2114410d0b1fa31293d427df9066238646d208c2878d20686a69bce6c80db5e548bee30e1b7c0ed45e3
|
7
|
+
data.tar.gz: 53b3202f0f8858de9ae4ac123750ebe29c873c989f73a1e1a63defd96ebc20c2e7e935c3f88e2c00685fff7e4eec33190b892788331181bf5e2780869b1684dc
|
data/.rubocop.yml
CHANGED
@@ -11,6 +11,7 @@ AllCops:
|
|
11
11
|
- vendor/**/*
|
12
12
|
- tmp/**/*
|
13
13
|
- test/source/**/*
|
14
|
+
- test/resources/src/_pages/*.rb
|
14
15
|
- lib/site_template/Rakefile
|
15
16
|
- lib/site_template/config.ru
|
16
17
|
- lib/site_template/config/**/*
|
@@ -30,6 +31,10 @@ Performance/CollectionLiteralInLoop:
|
|
30
31
|
Exclude:
|
31
32
|
- test/test_filters.rb
|
32
33
|
|
34
|
+
Style/OpenStructUse:
|
35
|
+
Exclude:
|
36
|
+
- test/**/*.rb
|
37
|
+
|
33
38
|
Style/StringConcatenation:
|
34
39
|
Exclude:
|
35
40
|
- test/test_apply_command.rb
|
data/bin/bridgetown
CHANGED
@@ -19,11 +19,18 @@ Bridgetown::PluginManager.require_from_bundler
|
|
19
19
|
# TODO: need to change behavior of Colorator gem
|
20
20
|
ENV["THOR_SHELL"] = "Basic" if ENV["NO_COLOR"]
|
21
21
|
|
22
|
-
output_version = if ARGV[0] == "-v"
|
22
|
+
output_version = if ARGV[0] == "-v" || ARGV[0] == "--version"
|
23
23
|
puts "bridgetown #{Bridgetown::VERSION} \"#{Bridgetown::CODE_NAME}\""
|
24
24
|
true
|
25
25
|
end
|
26
26
|
|
27
|
+
if env_index = ARGV.index { |arg| arg == "-e" } # rubocop:disable Lint/AssignmentInCondition
|
28
|
+
env = ARGV[env_index + 1]
|
29
|
+
ENV["BRIDGETOWN_ENV"] = env if env
|
30
|
+
elsif env_flag = ARGV.find { |arg| arg.start_with?("--environment=") } # rubocop:disable Lint/AssignmentInCondition
|
31
|
+
ENV["BRIDGETOWN_ENV"] = env_flag.split("=").last
|
32
|
+
end
|
33
|
+
|
27
34
|
ENV["RACK_ENV"] = ENV["BRIDGETOWN_ENV"]
|
28
35
|
|
29
36
|
require "bridgetown-core/commands/base"
|
data/bridgetown-core.gemspec
CHANGED
@@ -28,8 +28,7 @@ Gem::Specification.new do |s|
|
|
28
28
|
|
29
29
|
s.rdoc_options = ["--charset=UTF-8"]
|
30
30
|
|
31
|
-
s.required_ruby_version = ">= 2.
|
32
|
-
s.required_rubygems_version = ">= 2.7.0"
|
31
|
+
s.required_ruby_version = ">= 2.7.0"
|
33
32
|
|
34
33
|
s.add_runtime_dependency("activemodel", "~> 6.0")
|
35
34
|
s.add_runtime_dependency("activesupport", "~> 6.0")
|
@@ -44,14 +43,15 @@ Gem::Specification.new do |s|
|
|
44
43
|
s.add_runtime_dependency("kramdown", "~> 2.1")
|
45
44
|
s.add_runtime_dependency("kramdown-parser-gfm", "~> 1.0")
|
46
45
|
s.add_runtime_dependency("liquid", "~> 5.0")
|
47
|
-
s.add_runtime_dependency("liquid-component", ">= 0.1")
|
48
46
|
s.add_runtime_dependency("listen", "~> 3.0")
|
49
47
|
s.add_runtime_dependency("rack-indifferent", ">= 1.2.0")
|
50
48
|
s.add_runtime_dependency("rake", ">= 13.0")
|
51
49
|
s.add_runtime_dependency("roda", "~> 3.46")
|
52
50
|
s.add_runtime_dependency("rouge", "~> 3.0")
|
51
|
+
s.add_runtime_dependency("serbea", "~> 1.0")
|
53
52
|
s.add_runtime_dependency("terminal-table", "~> 1.8")
|
54
53
|
s.add_runtime_dependency("thor", "~> 1.1")
|
55
54
|
s.add_runtime_dependency("tilt", "~> 2.0")
|
56
55
|
s.add_runtime_dependency("webrick", "~> 1.7")
|
56
|
+
s.add_runtime_dependency("zeitwerk", "~> 2.5")
|
57
57
|
end
|
@@ -144,7 +144,7 @@ module Bridgetown
|
|
144
144
|
@base_dir ||= File.join(Bridgetown::Cache.cache_dir, @name)
|
145
145
|
return @base_dir if hash.nil?
|
146
146
|
|
147
|
-
File.join(@base_dir, hash[0..1], hash[2
|
147
|
+
File.join(@base_dir, hash[0..1], hash[2..]).freeze
|
148
148
|
end
|
149
149
|
|
150
150
|
# Given a key, return a SHA2 hash that can be used for caching this item to disk.
|
@@ -234,7 +234,7 @@ module Bridgetown
|
|
234
234
|
end
|
235
235
|
|
236
236
|
resources.each do |data_resource|
|
237
|
-
segments = data_resource.relative_path.each_filename.to_a[1
|
237
|
+
segments = data_resource.relative_path.each_filename.to_a[1..]
|
238
238
|
nested = []
|
239
239
|
segments.each_with_index do |segment, index|
|
240
240
|
sanitized_segment = sanitize_filename.(File.basename(segment, ".*"))
|
@@ -3,6 +3,13 @@
|
|
3
3
|
module Bridgetown
|
4
4
|
module Commands
|
5
5
|
module ConfigurationOverridable
|
6
|
+
def self.included(klass)
|
7
|
+
desc = "The environment used for this command (aka development, test, production, etc.)"
|
8
|
+
klass.class_option :environment,
|
9
|
+
aliases: "-e",
|
10
|
+
desc: desc
|
11
|
+
end
|
12
|
+
|
6
13
|
# Create a full Bridgetown configuration with the options passed in as overrides
|
7
14
|
#
|
8
15
|
# options - the configuration overrides
|
@@ -41,6 +41,7 @@ module Bridgetown
|
|
41
41
|
configuration_file = find_in_source_paths("#{configuration}.rb")
|
42
42
|
|
43
43
|
inside(New.created_site_dir || Dir.pwd) do
|
44
|
+
@templates_dir = File.expand_path("../configurations/#{configuration}", __dir__)
|
44
45
|
apply configuration_file, verbose: false
|
45
46
|
end
|
46
47
|
end
|
@@ -62,6 +63,12 @@ module Bridgetown
|
|
62
63
|
return Dir.glob("*.rb").map { |file| file.sub(".rb", "") }
|
63
64
|
end
|
64
65
|
end
|
66
|
+
|
67
|
+
def in_templates_dir(*paths)
|
68
|
+
paths.reduce(@templates_dir) do |base, path|
|
69
|
+
Bridgetown.sanitized_path(base, path.to_s)
|
70
|
+
end
|
71
|
+
end
|
65
72
|
end
|
66
73
|
end
|
67
74
|
end
|
@@ -1,6 +1,38 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Bridgetown
|
4
|
+
module ConsoleMethods
|
5
|
+
def site
|
6
|
+
Bridgetown::Current.site
|
7
|
+
end
|
8
|
+
|
9
|
+
def collections
|
10
|
+
site.collections
|
11
|
+
end
|
12
|
+
|
13
|
+
def reload!
|
14
|
+
Bridgetown.logger.info "Reloading site..."
|
15
|
+
|
16
|
+
I18n.reload! # make sure any locale files get read again
|
17
|
+
Bridgetown::Hooks.trigger :site, :pre_reload, site
|
18
|
+
Bridgetown::Hooks.clear_reloadable_hooks
|
19
|
+
site.plugin_manager.reload_plugin_files
|
20
|
+
site.loaders_manager.reload_loaders
|
21
|
+
|
22
|
+
ConsoleMethods.site_reset(site)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.site_reset(site)
|
26
|
+
site.reset
|
27
|
+
Bridgetown.logger.info "Reading files..."
|
28
|
+
site.read
|
29
|
+
Bridgetown.logger.info "", "done!"
|
30
|
+
Bridgetown.logger.info "Running generators..."
|
31
|
+
site.generate
|
32
|
+
Bridgetown.logger.info "", "done!"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
4
36
|
module Commands
|
5
37
|
class Console < Thor::Group
|
6
38
|
extend Summarizable
|
@@ -37,24 +69,18 @@ module Bridgetown
|
|
37
69
|
Bridgetown.logger.info "Environment:", Bridgetown.environment.cyan
|
38
70
|
site = Bridgetown::Site.new(configuration_with_overrides(options))
|
39
71
|
|
40
|
-
unless options[:blank]
|
41
|
-
site.reset
|
42
|
-
Bridgetown.logger.info "Reading files..."
|
43
|
-
site.read
|
44
|
-
Bridgetown.logger.info "", "done!"
|
45
|
-
Bridgetown.logger.info "Running generators..."
|
46
|
-
site.generate
|
47
|
-
Bridgetown.logger.info "", "done!"
|
48
|
-
end
|
72
|
+
ConsoleMethods.site_reset(site) unless options[:blank]
|
49
73
|
|
50
|
-
|
74
|
+
IRB::ExtendCommandBundle.include ConsoleMethods
|
51
75
|
IRB.setup(nil)
|
52
76
|
workspace = IRB::WorkSpace.new
|
53
77
|
irb = IRB::Irb.new(workspace)
|
54
78
|
IRB.conf[:IRB_RC]&.call(irb.context)
|
55
79
|
IRB.conf[:MAIN_CONTEXT] = irb.context
|
56
|
-
|
57
|
-
Bridgetown.logger.info "
|
80
|
+
Bridgetown.logger.info "Console:", "Your site is now available as #{"site".cyan}"
|
81
|
+
Bridgetown.logger.info "",
|
82
|
+
"You can also access #{"collections".cyan} or perform a" \
|
83
|
+
" #{"reload!".cyan}"
|
58
84
|
|
59
85
|
trap("SIGINT") do
|
60
86
|
irb.signal_handle
|
@@ -57,8 +57,7 @@ module Bridgetown
|
|
57
57
|
def conflicting_urls(site)
|
58
58
|
conflicting_urls = false
|
59
59
|
urls = {}
|
60
|
-
urls = collect_urls(urls, site.
|
61
|
-
urls = collect_urls(urls, site.collections.posts.docs, site.dest)
|
60
|
+
urls = collect_urls(urls, site.contents, site.dest)
|
62
61
|
urls.each do |url, paths|
|
63
62
|
next unless paths.size > 1
|
64
63
|
|
@@ -98,7 +97,11 @@ module Bridgetown
|
|
98
97
|
|
99
98
|
def collect_urls(urls, things, destination)
|
100
99
|
things.each do |thing|
|
101
|
-
dest = thing.
|
100
|
+
dest = if thing.method(:destination).arity == 1
|
101
|
+
thing.destination(destination)
|
102
|
+
else
|
103
|
+
thing.destination
|
104
|
+
end
|
102
105
|
if urls[dest]
|
103
106
|
urls[dest] << thing.path
|
104
107
|
else
|
@@ -110,8 +113,8 @@ module Bridgetown
|
|
110
113
|
|
111
114
|
def case_insensitive_urls(things, _destination)
|
112
115
|
things.each_with_object({}) do |thing, memo|
|
113
|
-
dest = thing.destination
|
114
|
-
(memo[dest.downcase] ||= []) << dest
|
116
|
+
dest = thing.destination&.output_path
|
117
|
+
(memo[dest.downcase] ||= []) << dest if dest
|
115
118
|
end
|
116
119
|
end
|
117
120
|
|
@@ -187,7 +187,7 @@ module Bridgetown
|
|
187
187
|
say_status "Done!", "Have fun writing your new #{name} plugin :)"
|
188
188
|
say_status "Remember:", "Don't forget to rename the SamplePlugin" \
|
189
189
|
" code identifiers and paths to your own" \
|
190
|
-
" indentifer, as well as update your README
|
190
|
+
" indentifer, as well as update your README" \
|
191
191
|
" and CHANGELOG files as necessary."
|
192
192
|
end
|
193
193
|
|
@@ -164,9 +164,9 @@ module Bridgetown
|
|
164
164
|
end
|
165
165
|
end
|
166
166
|
|
167
|
-
|
167
|
+
def method_missing(method, *args, **kwargs, &block)
|
168
168
|
if helpers.respond_to?(method.to_sym)
|
169
|
-
helpers.send method.to_sym, *args, &block
|
169
|
+
helpers.send method.to_sym, *args, **kwargs, &block
|
170
170
|
else
|
171
171
|
super
|
172
172
|
end
|
@@ -32,7 +32,7 @@ module Bridgetown
|
|
32
32
|
self.front_matter_line_count = ruby_content[1].lines.size
|
33
33
|
process_ruby_data(ruby_content[1], file_path, 2)
|
34
34
|
elsif Bridgetown::Utils.has_rbfm_header?(file_path)
|
35
|
-
process_ruby_data(File.read(file_path).lines[1
|
35
|
+
process_ruby_data(File.read(file_path).lines[1..].join("\n"), file_path, 2)
|
36
36
|
elsif is_a?(Layout)
|
37
37
|
self.content = file_contents
|
38
38
|
{}
|
@@ -155,10 +155,10 @@ class Bridgetown::Site
|
|
155
155
|
Bridgetown::Cache.disable_disk_cache! if config["disable_disk_cache"]
|
156
156
|
end
|
157
157
|
|
158
|
-
def configure_component_paths
|
158
|
+
def configure_component_paths # rubocop:todo Metrics/AbcSize
|
159
159
|
# Loop through plugins paths first
|
160
160
|
plugin_components_load_paths = Bridgetown::PluginManager.source_manifests
|
161
|
-
.
|
161
|
+
.filter_map(&:components)
|
162
162
|
|
163
163
|
local_components_load_paths = config["components_dir"].yield_self do |dir|
|
164
164
|
dir.is_a?(Array) ? dir : [dir]
|
@@ -172,7 +172,10 @@ class Bridgetown::Site
|
|
172
172
|
end
|
173
173
|
end
|
174
174
|
|
175
|
-
|
175
|
+
config.components_load_paths = plugin_components_load_paths + local_components_load_paths
|
176
|
+
# Because "first constant wins" in Zeitwerk, we need to load the local
|
177
|
+
# source components _before_ we load any from plugins
|
178
|
+
config.autoload_paths += config.components_load_paths.reverse
|
176
179
|
end
|
177
180
|
|
178
181
|
def configure_file_read_opts
|
@@ -3,13 +3,14 @@
|
|
3
3
|
class Bridgetown::Site
|
4
4
|
module Extensible
|
5
5
|
# Load necessary libraries, plugins, converters, and generators.
|
6
|
+
# This is only ever run once for the lifecycle of the site object.
|
6
7
|
# @see Converter
|
7
8
|
# @see Generator
|
8
9
|
# @see PluginManager
|
9
10
|
# @return [void]
|
10
11
|
def setup
|
11
12
|
plugin_manager.require_plugin_files
|
12
|
-
|
13
|
+
loaders_manager.setup_loaders
|
13
14
|
self.converters = instantiate_subclasses(Bridgetown::Converter)
|
14
15
|
self.generators = instantiate_subclasses(Bridgetown::Generator)
|
15
16
|
end
|
@@ -8,29 +8,16 @@ class Bridgetown::Site
|
|
8
8
|
|
9
9
|
module ClassMethods
|
10
10
|
# Establish an SSR pipeline for a persistent backend process
|
11
|
-
def start_ssr!
|
11
|
+
def start_ssr!(loaders_manager: nil, &block)
|
12
12
|
if Bridgetown::Current.site
|
13
13
|
raise Bridgetown::Errors::FatalException, "Bridgetown SSR already started! " \
|
14
14
|
"Check your Rack app for threading issues"
|
15
15
|
end
|
16
16
|
|
17
17
|
Bridgetown::PluginManager.require_from_bundler
|
18
|
-
site = new(Bridgetown::Current.preloaded_configuration)
|
18
|
+
site = new(Bridgetown::Current.preloaded_configuration, loaders_manager: loaders_manager)
|
19
19
|
site.enable_ssr
|
20
|
-
|
21
|
-
Bridgetown::Hooks.trigger :site, :pre_read, site
|
22
|
-
site.defaults_reader.tap do |d|
|
23
|
-
d.path_defaults.clear
|
24
|
-
d.read
|
25
|
-
end
|
26
|
-
site.layouts = Bridgetown::LayoutReader.new(site).read
|
27
|
-
site.collections.data.tap do |coll|
|
28
|
-
coll.read
|
29
|
-
site.data = coll.merge_data_resources
|
30
|
-
end
|
31
|
-
Bridgetown::Hooks.trigger :site, :post_read, site
|
32
|
-
|
33
|
-
yield(site) if block_given? # provide additional setup hook
|
20
|
+
site.ssr_setup(&block)
|
34
21
|
|
35
22
|
site
|
36
23
|
end
|
@@ -45,6 +32,41 @@ class Bridgetown::Site
|
|
45
32
|
@ssr_enabled = true
|
46
33
|
end
|
47
34
|
|
35
|
+
def ssr_setup(&block) # rubocop:disable Metrics/AbcSize
|
36
|
+
config.serving = true
|
37
|
+
Bridgetown::Hooks.trigger :site, :pre_read, self
|
38
|
+
defaults_reader.tap do |d|
|
39
|
+
d.path_defaults.clear
|
40
|
+
d.read
|
41
|
+
end
|
42
|
+
reader.read_layouts
|
43
|
+
collections.data.tap do |coll|
|
44
|
+
coll.read
|
45
|
+
self.data = coll.merge_data_resources
|
46
|
+
end
|
47
|
+
Bridgetown::Hooks.trigger :site, :post_read, self
|
48
|
+
|
49
|
+
hook = block&.(self) # provide additional setup hook
|
50
|
+
return if Bridgetown.env.production?
|
51
|
+
|
52
|
+
@ssr_reload_hook = hook if hook.is_a?(Proc) && hook.lambda?
|
53
|
+
Bridgetown::Watcher.watch(self, config)
|
54
|
+
end
|
55
|
+
|
56
|
+
def ssr_reload
|
57
|
+
reset soft: true
|
58
|
+
reader.read_layouts
|
59
|
+
|
60
|
+
collections.data.tap do |coll|
|
61
|
+
coll.resources.clear
|
62
|
+
coll.read
|
63
|
+
coll.merge_data_resources.each do |k, v|
|
64
|
+
data[k] = v
|
65
|
+
end
|
66
|
+
end
|
67
|
+
@ssr_reload_hook.() if @ssr_reload_hook.is_a?(Proc)
|
68
|
+
end
|
69
|
+
|
48
70
|
def disable_ssr
|
49
71
|
Bridgetown.logger.info "SSR:", "now disabled."
|
50
72
|
@ssr_enabled = false
|
@@ -11,64 +11,68 @@ module Bridgetown
|
|
11
11
|
# Strings rather than symbols are used for compatibility with YAML.
|
12
12
|
DEFAULTS = {
|
13
13
|
# Where things are
|
14
|
-
"root_dir"
|
15
|
-
"plugins_dir"
|
16
|
-
"source"
|
17
|
-
"destination"
|
18
|
-
"collections_dir"
|
19
|
-
"cache_dir"
|
20
|
-
"layouts_dir"
|
21
|
-
"data_dir"
|
22
|
-
"components_dir"
|
23
|
-
"partials_dir"
|
24
|
-
"collections"
|
25
|
-
"taxonomies"
|
14
|
+
"root_dir" => Dir.pwd,
|
15
|
+
"plugins_dir" => "plugins",
|
16
|
+
"source" => File.join(Dir.pwd, "src"),
|
17
|
+
"destination" => File.join(Dir.pwd, "output"),
|
18
|
+
"collections_dir" => "",
|
19
|
+
"cache_dir" => ".bridgetown-cache",
|
20
|
+
"layouts_dir" => "_layouts",
|
21
|
+
"data_dir" => "_data",
|
22
|
+
"components_dir" => "_components",
|
23
|
+
"partials_dir" => "_partials",
|
24
|
+
"collections" => {},
|
25
|
+
"taxonomies" => {
|
26
26
|
category: { key: "categories", title: "Category" }, tag: { key: "tags", title: "Tag" },
|
27
27
|
},
|
28
|
+
"autoload_paths" => [],
|
29
|
+
"eager_load_paths" => [],
|
30
|
+
"autoloader_collapsed_paths" => [],
|
31
|
+
"plugins_use_zeitwerk" => true,
|
28
32
|
|
29
33
|
# Handling Reading
|
30
|
-
"include"
|
31
|
-
"exclude"
|
32
|
-
"keep_files"
|
33
|
-
"encoding"
|
34
|
-
"markdown_ext"
|
35
|
-
"strict_front_matter"
|
36
|
-
"slugify_mode"
|
34
|
+
"include" => [".htaccess", "_redirects", ".well-known"],
|
35
|
+
"exclude" => [],
|
36
|
+
"keep_files" => [".git", ".svn", "_bridgetown"],
|
37
|
+
"encoding" => "utf-8",
|
38
|
+
"markdown_ext" => "markdown,mkdown,mkdn,mkd,md",
|
39
|
+
"strict_front_matter" => false,
|
40
|
+
"slugify_mode" => "pretty",
|
37
41
|
|
38
42
|
# Filtering Content
|
39
|
-
"future"
|
40
|
-
"unpublished"
|
41
|
-
"ruby_in_front_matter"
|
43
|
+
"future" => false,
|
44
|
+
"unpublished" => false,
|
45
|
+
"ruby_in_front_matter" => true,
|
42
46
|
|
43
47
|
# Conversion
|
44
|
-
"content_engine"
|
45
|
-
"markdown"
|
46
|
-
"highlighter"
|
47
|
-
"excerpt_separator"
|
48
|
+
"content_engine" => "resource",
|
49
|
+
"markdown" => "kramdown",
|
50
|
+
"highlighter" => "rouge",
|
51
|
+
"excerpt_separator" => "\n\n",
|
48
52
|
|
49
53
|
# Serving
|
50
|
-
"port"
|
51
|
-
"host"
|
52
|
-
"base_path"
|
53
|
-
"show_dir_listing"
|
54
|
+
"port" => "4000",
|
55
|
+
"host" => "127.0.0.1",
|
56
|
+
"base_path" => "/",
|
57
|
+
"show_dir_listing" => false,
|
54
58
|
|
55
59
|
# Output Configuration
|
56
|
-
"available_locales"
|
57
|
-
"default_locale"
|
58
|
-
"permalink"
|
59
|
-
"timezone"
|
60
|
+
"available_locales" => [:en],
|
61
|
+
"default_locale" => :en,
|
62
|
+
"permalink" => nil, # default is set according to content engine
|
63
|
+
"timezone" => nil, # use the local timezone
|
60
64
|
|
61
|
-
"quiet"
|
62
|
-
"verbose"
|
63
|
-
"defaults"
|
65
|
+
"quiet" => false,
|
66
|
+
"verbose" => false,
|
67
|
+
"defaults" => [],
|
64
68
|
|
65
|
-
"liquid"
|
69
|
+
"liquid" => {
|
66
70
|
"error_mode" => "warn",
|
67
71
|
"strict_filters" => false,
|
68
72
|
"strict_variables" => false,
|
69
73
|
},
|
70
74
|
|
71
|
-
"kramdown"
|
75
|
+
"kramdown" => {
|
72
76
|
"auto_ids" => true,
|
73
77
|
"toc_levels" => (1..6).to_a,
|
74
78
|
"entity_output" => "as_char",
|
@@ -98,6 +102,7 @@ module Bridgetown
|
|
98
102
|
def from(user_config, starting_defaults = DEFAULTS)
|
99
103
|
Utils.deep_merge_hashes(starting_defaults.deep_dup, Configuration[user_config])
|
100
104
|
.merge_environment_specific_options!
|
105
|
+
.setup_load_paths!
|
101
106
|
.setup_locales
|
102
107
|
.add_default_collections
|
103
108
|
.add_default_excludes
|
@@ -109,21 +114,21 @@ module Bridgetown
|
|
109
114
|
override[config_key] || self[config_key] || DEFAULTS[config_key]
|
110
115
|
end
|
111
116
|
|
112
|
-
#
|
117
|
+
# Directory of the top-level root where config files are located
|
113
118
|
#
|
114
|
-
# override
|
119
|
+
# @param override [Hash] options hash which will override value if key is present
|
115
120
|
#
|
116
|
-
#
|
117
|
-
def root_dir(override =
|
121
|
+
# @return [String] path to the Bridgetown root directory
|
122
|
+
def root_dir(override = {})
|
118
123
|
get_config_value_with_override("root_dir", override)
|
119
124
|
end
|
120
125
|
|
121
126
|
# Public: Directory of the Bridgetown source folder
|
122
127
|
#
|
123
|
-
# override
|
128
|
+
# @param override [Hash] options hash which will override value if key is present
|
124
129
|
#
|
125
|
-
#
|
126
|
-
def source(override =
|
130
|
+
# @return [String] path to the Bridgetown source directory
|
131
|
+
def source(override = {})
|
127
132
|
get_config_value_with_override("source", override)
|
128
133
|
end
|
129
134
|
|
@@ -240,6 +245,32 @@ module Bridgetown
|
|
240
245
|
self[k] = self[Bridgetown.environment][k]
|
241
246
|
end
|
242
247
|
delete(Bridgetown.environment)
|
248
|
+
|
249
|
+
self
|
250
|
+
end
|
251
|
+
|
252
|
+
def setup_load_paths!
|
253
|
+
if self[:plugins_use_zeitwerk]
|
254
|
+
autoload_paths.unshift({
|
255
|
+
path: self[:plugins_dir],
|
256
|
+
eager: true,
|
257
|
+
})
|
258
|
+
end
|
259
|
+
|
260
|
+
autoload_paths.map! do |load_path|
|
261
|
+
if load_path.is_a?(Hash)
|
262
|
+
expanded = File.expand_path(load_path[:path], root_dir)
|
263
|
+
self[:eager_load_paths] << expanded if load_path[:eager]
|
264
|
+
next expanded
|
265
|
+
end
|
266
|
+
|
267
|
+
File.expand_path(load_path, root_dir)
|
268
|
+
end
|
269
|
+
|
270
|
+
autoloader_collapsed_paths.map! do |collapsed_path|
|
271
|
+
File.expand_path(collapsed_path, root_dir)
|
272
|
+
end
|
273
|
+
|
243
274
|
self
|
244
275
|
end
|
245
276
|
|
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
# rubocop:disable all
|
4
4
|
|
5
|
-
TEMPLATE_PATH = File.expand_path("./bt-postcss", __dir__)
|
6
|
-
|
7
5
|
unless File.exist?("postcss.config.js")
|
8
6
|
error_message = "#{"postcss.config.js".bold} not found. Please configure postcss in your project."
|
9
7
|
|
@@ -21,6 +19,6 @@ plugins = %w(postcss-easy-import postcss-mixins postcss-color-function cssnano)
|
|
21
19
|
say "Adding the following PostCSS plugins: #{plugins.join(' | ')}", :green
|
22
20
|
run "yarn add -D #{plugins.join(' ')}"
|
23
21
|
|
24
|
-
copy_file "
|
22
|
+
copy_file in_templates_dir("postcss.config.js"), "postcss.config.js", force: true
|
25
23
|
|
26
24
|
# rubocop:enable all
|
@@ -0,0 +1,17 @@
|
|
1
|
+
describe("Testing that links exist in the navbar", () => {
|
2
|
+
beforeEach(() => {
|
3
|
+
cy.visit("/");
|
4
|
+
});
|
5
|
+
it("navbar links appear on all pages", () => {
|
6
|
+
const baseUrl = Cypress.config("baseUrl");
|
7
|
+
|
8
|
+
cy.get('[href="/"]').click();
|
9
|
+
cy.url().should("eq", baseUrl + "/");
|
10
|
+
|
11
|
+
cy.get('[href="/posts"]').click();
|
12
|
+
cy.url().should("eq", baseUrl + "/posts");
|
13
|
+
|
14
|
+
cy.get('[href="/about"]').click();
|
15
|
+
cy.url().should("eq", baseUrl + "/about");
|
16
|
+
});
|
17
|
+
});
|
@@ -0,0 +1,21 @@
|
|
1
|
+
/// <reference types="cypress" />
|
2
|
+
// ***********************************************************
|
3
|
+
// This example plugins/index.js can be used to load plugins
|
4
|
+
//
|
5
|
+
// You can change the location of this file or turn off loading
|
6
|
+
// the plugins file with the 'pluginsFile' configuration option.
|
7
|
+
//
|
8
|
+
// You can read more here:
|
9
|
+
// https://on.cypress.io/plugins-guide
|
10
|
+
// ***********************************************************
|
11
|
+
|
12
|
+
// This function is called when a project is opened or re-opened (e.g. due to
|
13
|
+
// the project's config changing)
|
14
|
+
|
15
|
+
/**
|
16
|
+
* @type {Cypress.PluginConfig}
|
17
|
+
*/
|
18
|
+
module.exports = (on, config) => {
|
19
|
+
// `on` is used to hook into various events Cypress emits
|
20
|
+
// `config` is the resolved Cypress config
|
21
|
+
}
|