bridgetown-core 2.0.0.beta2 → 2.0.0.beta4

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.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/bridgetown-core.gemspec +43 -42
  4. data/lib/bridgetown-core/cache.rb +3 -19
  5. data/lib/bridgetown-core/cleaner.rb +17 -19
  6. data/lib/bridgetown-core/collection.rb +6 -5
  7. data/lib/bridgetown-core/commands/base.rb +7 -0
  8. data/lib/bridgetown-core/commands/build.rb +35 -22
  9. data/lib/bridgetown-core/commands/concerns/actions.rb +4 -0
  10. data/lib/bridgetown-core/commands/console.rb +0 -1
  11. data/lib/bridgetown-core/commands/esbuild/esbuild.config.js +7 -6
  12. data/lib/bridgetown-core/commands/esbuild/esbuild.defaults.js.erb +14 -13
  13. data/lib/bridgetown-core/commands/esbuild/migrate-from-webpack.rb +1 -1
  14. data/lib/bridgetown-core/commands/esbuild/update.rb +17 -3
  15. data/lib/bridgetown-core/commands/esbuild.rb +1 -1
  16. data/lib/bridgetown-core/commands/start.rb +12 -2
  17. data/lib/bridgetown-core/component.rb +1 -1
  18. data/lib/bridgetown-core/concerns/intuitive_expectations.rb +67 -0
  19. data/lib/bridgetown-core/concerns/layout_placeable.rb +1 -1
  20. data/lib/bridgetown-core/concerns/publishable.rb +2 -0
  21. data/lib/bridgetown-core/concerns/site/content.rb +4 -1
  22. data/lib/bridgetown-core/concerns/site/extensible.rb +6 -1
  23. data/lib/bridgetown-core/concerns/site/fast_refreshable.rb +33 -18
  24. data/lib/bridgetown-core/concerns/site/localizable.rb +2 -0
  25. data/lib/bridgetown-core/concerns/site/processable.rb +2 -0
  26. data/lib/bridgetown-core/concerns/site/renderable.rb +3 -0
  27. data/lib/bridgetown-core/concerns/site/ssr.rb +1 -2
  28. data/lib/bridgetown-core/concerns/site/writable.rb +1 -0
  29. data/lib/bridgetown-core/concerns/viewable.rb +46 -0
  30. data/lib/bridgetown-core/configuration.rb +29 -23
  31. data/lib/bridgetown-core/configurations/gh-pages/gh-pages.yml +5 -5
  32. data/lib/bridgetown-core/configurations/minitesting.rb +24 -64
  33. data/lib/bridgetown-core/converter.rb +2 -7
  34. data/lib/bridgetown-core/converters/erb_templates.rb +11 -7
  35. data/lib/bridgetown-core/converters/identity.rb +3 -11
  36. data/lib/bridgetown-core/converters/liquid_templates.rb +3 -5
  37. data/lib/bridgetown-core/converters/markdown/kramdown_parser.rb +1 -1
  38. data/lib/bridgetown-core/converters/markdown.rb +11 -14
  39. data/lib/bridgetown-core/converters/serbea_templates.rb +10 -8
  40. data/lib/bridgetown-core/drops/drop.rb +29 -42
  41. data/lib/bridgetown-core/drops/resource_drop.rb +3 -12
  42. data/lib/bridgetown-core/errors.rb +2 -8
  43. data/lib/bridgetown-core/filters/condition_helpers.rb +6 -9
  44. data/lib/bridgetown-core/filters/date_filters.rb +22 -35
  45. data/lib/bridgetown-core/filters/grouping_filters.rb +11 -11
  46. data/lib/bridgetown-core/filters.rb +53 -72
  47. data/lib/bridgetown-core/front_matter/defaults.rb +14 -19
  48. data/lib/bridgetown-core/generated_page.rb +6 -6
  49. data/lib/bridgetown-core/generators/prototype_generator.rb +0 -2
  50. data/lib/bridgetown-core/helpers.rb +2 -2
  51. data/lib/bridgetown-core/hooks.rb +0 -1
  52. data/lib/bridgetown-core/layout.rb +3 -4
  53. data/lib/bridgetown-core/liquid_extensions.rb +3 -5
  54. data/lib/bridgetown-core/log_adapter.rb +37 -56
  55. data/lib/bridgetown-core/plugin_manager.rb +7 -3
  56. data/lib/bridgetown-core/rack/boot.rb +7 -57
  57. data/lib/bridgetown-core/rack/default_config.ru +14 -0
  58. data/lib/bridgetown-core/rack/loader_hooks.rb +83 -0
  59. data/lib/bridgetown-core/rack/logger.rb +0 -2
  60. data/lib/bridgetown-core/rack/routes.rb +3 -2
  61. data/lib/bridgetown-core/resource/base.rb +8 -8
  62. data/lib/bridgetown-core/resource/permalink_processor.rb +1 -1
  63. data/lib/bridgetown-core/resource/relations.rb +3 -1
  64. data/lib/bridgetown-core/ruby_template_view.rb +0 -1
  65. data/lib/bridgetown-core/static_file.rb +15 -20
  66. data/lib/bridgetown-core/tags/class_map.rb +1 -1
  67. data/lib/bridgetown-core/tags/post_url.rb +2 -32
  68. data/lib/bridgetown-core/utils/initializers.rb +2 -2
  69. data/lib/bridgetown-core/utils/require_gems.rb +1 -3
  70. data/lib/bridgetown-core/utils.rb +41 -44
  71. data/lib/bridgetown-core/watcher.rb +2 -3
  72. data/lib/bridgetown-core.rb +29 -10
  73. data/lib/roda/plugins/bridgetown_server.rb +13 -25
  74. data/lib/roda/plugins/bridgetown_ssr.rb +21 -3
  75. data/lib/roda/plugins/flashier.rb +57 -0
  76. data/lib/roda/plugins/generic_index.html +127 -0
  77. data/lib/roda/plugins/ssg.rb +3 -2
  78. data/lib/site_template/config/initializers.rb +2 -0
  79. data/lib/site_template/package.json.erb +1 -0
  80. data/lib/site_template/postcss.config.js.erb +1 -1
  81. metadata +26 -7
  82. data/lib/bridgetown-core/commands/doctor.rb +0 -147
@@ -77,12 +77,14 @@ module Bridgetown
77
77
  bt_bound_url = "http://#{bt_options.bind}:#{port}"
78
78
 
79
79
  # Set a local site URL in the config if one is not available
80
- bt_options.url = bt_bound_url if Bridgetown.env.development? && !options["url"]
80
+ if Bridgetown.env.development? && !options["url"]
81
+ bt_options.url = bt_bound_url.sub("0.0.0.0", "localhost")
82
+ end
81
83
 
82
84
  Bridgetown::Server.new({
83
85
  Host: bt_options.bind,
84
86
  Port: port,
85
- config: "config.ru",
87
+ config: rack_config_file,
86
88
  }).tap do |server|
87
89
  if server.serveable?
88
90
  pid_tracker.create_pid_dir
@@ -115,6 +117,14 @@ module Bridgetown
115
117
  end
116
118
  end
117
119
  end
120
+
121
+ protected
122
+
123
+ def rack_config_file
124
+ File.exist?("config.ru") ?
125
+ "config.ru" :
126
+ File.expand_path("../rack/default_config.ru", __dir__)
127
+ end
118
128
  end
119
129
  end
120
130
  end
@@ -94,7 +94,7 @@ module Bridgetown
94
94
 
95
95
  def path_for_errors
96
96
  File.basename(component_template_path)
97
- rescue RuntimeError
97
+ rescue RuntimeError, TypeError
98
98
  source_location
99
99
  end
100
100
  end
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bridgetown
4
+ # This is for including into Minitest::Expectation
5
+ module IntuitiveExpectations
6
+ def true?(msg = nil)
7
+ must_be(:itself, Minitest::Assertions::UNDEFINED, msg)
8
+ self
9
+ end
10
+
11
+ def false?(msg = nil)
12
+ wont_be(:itself, Minitest::Assertions::UNDEFINED, msg)
13
+ self
14
+ end
15
+
16
+ def ==(other)
17
+ must_equal(other)
18
+ self
19
+ end
20
+
21
+ def !=(other)
22
+ must_not_equal(other)
23
+ self
24
+ end
25
+
26
+ def nil?(msg = nil)
27
+ must_be_nil(msg)
28
+ self
29
+ end
30
+
31
+ def not_nil?(msg = nil)
32
+ wont_be_nil(msg)
33
+ self
34
+ end
35
+
36
+ def empty?(msg = nil)
37
+ must_be_empty(msg)
38
+ self
39
+ end
40
+
41
+ def filled?(msg = nil)
42
+ wont_be_empty(msg)
43
+ self
44
+ end
45
+
46
+ def include?(other, msg = nil)
47
+ must_include(other, msg)
48
+ self
49
+ end
50
+ alias_method :<<, :include?
51
+
52
+ def exclude?(other, msg = nil)
53
+ wont_include(other, msg)
54
+ self
55
+ end
56
+
57
+ def =~(other)
58
+ must_match(other)
59
+ self
60
+ end
61
+
62
+ def is_a?(klass, msg = nil)
63
+ must_be_instance_of(klass, msg)
64
+ self
65
+ end
66
+ end
67
+ end
@@ -4,7 +4,7 @@ module Bridgetown
4
4
  module LayoutPlaceable
5
5
  # Determine whether the file should be placed into layouts.
6
6
  #
7
- # Returns false if the document is an asset file or if the front matter
7
+ # @return [Boolean] false if the document is an asset file or if the front matter
8
8
  # specifies `layout: none`
9
9
  def place_in_layout?
10
10
  no_layout?.!
@@ -3,6 +3,8 @@
3
3
  module Bridgetown
4
4
  module Publishable
5
5
  # Whether the resource is published or not, as indicated in YAML front-matter
6
+ #
7
+ # @return [Boolean]
6
8
  def published?
7
9
  !(data.key?("published") && data["published"] == false)
8
10
  end
@@ -27,6 +27,7 @@ class Bridgetown::Site
27
27
  end
28
28
 
29
29
  # Returns the contents of the site metadata file or a blank hash
30
+ #
30
31
  # @return [HashWithDotAccess::Hash] Returns a hash of site metadata
31
32
  def metadata
32
33
  signals["site_metadata"] ||= HashWithDotAccess::Hash.new
@@ -49,7 +50,6 @@ class Bridgetown::Site
49
50
  #
50
51
  # @return [HashWithDotAccess::Hash{String, Symbol => Collection}] A Hash
51
52
  # containing a collection name-to-instance pairs.
52
- #
53
53
  # @return [HashWithDotAccess::Hash] Returns a blank hash if no items found
54
54
  def collections
55
55
  @collections ||= collection_names.each_with_object(
@@ -60,6 +60,7 @@ class Bridgetown::Site
60
60
  end
61
61
 
62
62
  # An array of collection names.
63
+ #
63
64
  # @return [Array<String>] an array of collection names from the configuration,
64
65
  # or an empty array if the `config["collections"]` key is not set.
65
66
  def collection_names
@@ -84,6 +85,7 @@ class Bridgetown::Site
84
85
  end
85
86
 
86
87
  # Get all loaded resources.
88
+ #
87
89
  # @return [Array<Bridgetown::Resource::Base>] an array of resources
88
90
  def resources
89
91
  collections.each_with_object(Set.new) do |(_, collection), set|
@@ -112,6 +114,7 @@ class Bridgetown::Site
112
114
  end
113
115
 
114
116
  # Loads and memoizes the parsed frontend bundler manifest file (if available)
117
+ #
115
118
  # @return [Hash]
116
119
  def frontend_manifest
117
120
  @frontend_manifest ||= begin
@@ -4,6 +4,7 @@ class Bridgetown::Site
4
4
  module Extensible
5
5
  # Load necessary libraries, plugins, converters, and generators.
6
6
  # This is only ever run once for the lifecycle of the site object.
7
+ #
7
8
  # @see Converter
8
9
  # @see Generator
9
10
  # @see PluginManager
@@ -16,6 +17,7 @@ class Bridgetown::Site
16
17
  end
17
18
 
18
19
  # Run all Generators.
20
+ #
19
21
  # @see Generator
20
22
  # @return [void]
21
23
  def generate
@@ -34,6 +36,7 @@ class Bridgetown::Site
34
36
  end
35
37
 
36
38
  # Get the implementation for the given Converter class.
39
+ #
37
40
  # @param klass [Class] The Class of the Converter to fetch.
38
41
  # @return [Converter] Returns the {Converter}
39
42
  # instance implementing the given `Converter` class.
@@ -46,7 +49,8 @@ class Bridgetown::Site
46
49
 
47
50
  # Create an array of instances of the subclasses of the class
48
51
  # passed in as argument.
49
- # @param klass [Class] - class which is the parent of the subclasses.
52
+ #
53
+ # @param klass [Class] class which is the parent of the subclasses.
50
54
  # @return [Array<Converter, Generator>] Returns an array of instances of
51
55
  # subclasses of `klass`.
52
56
  def instantiate_subclasses(klass)
@@ -56,6 +60,7 @@ class Bridgetown::Site
56
60
  end
57
61
 
58
62
  # Shorthand for registering a site hook via {Bridgetown::Hooks}
63
+ #
59
64
  # @param event [Symbol] name of the event (`:pre_read`, `:post_render`, etc.)
60
65
  # @yield the block will be called when the event is triggered
61
66
  # @yieldparam site the site which triggered the event hook
@@ -10,15 +10,17 @@ class Bridgetown::Site
10
10
  @fast_refresh_ordering = 0
11
11
  full_abort = false
12
12
  found_gen_pages = false
13
- paths.each do |path|
14
- res = resources.find do |resource|
13
+ found_route_file = false
14
+ paths.each do |path| # rubocop:todo Metrics
15
+ found_res = resources.select do |resource|
15
16
  resource.id.start_with?("repo://") && in_source_dir(resource.relative_path) == path
16
17
  end
17
18
 
18
19
  layouts_to_reload = Set.new
19
- locate_resource_layouts_and_partials_for_fash_refresh(path, layouts_to_reload) unless res
20
+ locate_resource_layouts_and_partials_for_fash_refresh(path, layouts_to_reload) unless
21
+ found_res.any?
20
22
 
21
- locate_components_for_fast_refresh(path) unless res
23
+ locate_components_for_fast_refresh(path) unless found_res.any?
22
24
 
23
25
  pages = locate_layouts_and_pages_for_fast_refresh(path, layouts_to_reload)
24
26
 
@@ -27,26 +29,33 @@ class Bridgetown::Site
27
29
  self, layout.instance_variable_get(:@base), layout.name
28
30
  )
29
31
  end
30
- liquid_renderer.reset unless layouts_to_reload.empty?
31
- next unless res || !pages.empty?
32
32
 
33
- unless pages.empty?
33
+ if config.key?(:routes) # carve out fast refresh track for the routes plugin
34
+ found_route_file = config.routes.source_paths.any? do |routes_dir|
35
+ path.start_with?(in_source_dir(routes_dir))
36
+ end
37
+ end
38
+ next unless found_res.any? || pages.any? || found_route_file
39
+
40
+ if pages.any?
34
41
  found_gen_pages = true
35
42
  mark_original_page_resources_for_fast_refresh(pages)
36
43
  next
37
44
  end
38
45
 
39
- res.prepare_for_fast_refresh!.tap { full_abort = true unless _1 }
40
- next unless res.collection.data?
46
+ found_res.each do |res|
47
+ res.prepare_for_fast_refresh!.tap { full_abort = true unless _1 }
48
+ next unless res.collection.data?
41
49
 
42
- res.collection.merge_data_resources.each do |k, v|
43
- data[k] = v
44
- signals[k] = v
50
+ res.collection.merge_data_resources.each do |k, v|
51
+ data[k] = v
52
+ signals[k] = v
53
+ end
45
54
  end
46
55
  end
47
56
 
48
57
  marked_resources = resources.select(&:fast_refresh_order).sort_by(&:fast_refresh_order)
49
- if full_abort || (marked_resources.empty? && !found_gen_pages)
58
+ if full_abort || (marked_resources.empty? && !found_gen_pages && !found_route_file)
50
59
  # Darn, a full reload is needed (unless we're on a super-fast track)
51
60
  if reload_if_needed
52
61
  Bridgetown::Hooks.trigger :site, :pre_reload, self, paths
@@ -60,12 +69,14 @@ class Bridgetown::Site
60
69
 
61
70
  Bridgetown::Hooks.trigger :site, :fast_refresh, self
62
71
 
63
- transform_resources_for_fast_refresh(marked_resources, found_gen_pages)
64
- transform_generated_pages_for_fast_refresh
65
-
66
- FileUtils.touch(in_destination_dir("index.html"))
72
+ unless found_route_file
73
+ liquid_renderer.reset
74
+ transform_resources_for_fast_refresh(marked_resources, found_gen_pages)
75
+ transform_generated_pages_for_fast_refresh
76
+ end
67
77
 
68
78
  Bridgetown::Hooks.trigger :site, :post_write, self
79
+ Bridgetown.touch_live_reload_file
69
80
  end
70
81
 
71
82
  private
@@ -134,7 +145,11 @@ class Bridgetown::Site
134
145
  end
135
146
 
136
147
  def transform_resources_for_fast_refresh(marked_resources, found_gen_pages)
137
- marked_resources.each { _1.transform!.write }
148
+ marked_resources.each do |res|
149
+ render_with_locale(res) do
150
+ res.transform!.write
151
+ end
152
+ end
138
153
  number_of_resources = marked_resources.length
139
154
  number_of_resources += 1 if found_gen_pages
140
155
  Bridgetown.logger.info(
@@ -3,6 +3,7 @@
3
3
  class Bridgetown::Site
4
4
  module Localizable
5
5
  # Returns the current and/or default configured locale
6
+ #
6
7
  # @return String
7
8
  def locale
8
9
  @locale ||= begin
@@ -16,6 +17,7 @@ class Bridgetown::Site
16
17
  end
17
18
 
18
19
  # Sets the current locale for the site
20
+ #
19
21
  # @param new_locale [String] for example: "en" for English, "es" for Spanish
20
22
  def locale=(new_locale)
21
23
  I18n.locale = @locale = new_locale.to_sym
@@ -3,6 +3,7 @@
3
3
  class Bridgetown::Site
4
4
  module Processable
5
5
  # Reset, Read, Generate, Render, Cleanup, Process, and Write this Site to output.
6
+ #
6
7
  # @return [void]
7
8
  # @see #reset
8
9
  # @see #read
@@ -67,6 +68,7 @@ class Bridgetown::Site
67
68
  end
68
69
 
69
70
  # Read data from disk and load it into internal memory.
71
+ #
70
72
  # @return [void]
71
73
  def read
72
74
  Bridgetown::Hooks.trigger :site, :pre_read, self
@@ -3,6 +3,7 @@
3
3
  class Bridgetown::Site
4
4
  module Renderable
5
5
  # Render all pages & documents so they're ready to be written out to disk.
6
+ #
6
7
  # @return [void]
7
8
  # @see Page
8
9
  # @see Document
@@ -97,6 +98,7 @@ class Bridgetown::Site
97
98
  end
98
99
 
99
100
  # Renders all resources
101
+ #
100
102
  # @return [void]
101
103
  def render_resources
102
104
  collections.each_value do |collection|
@@ -109,6 +111,7 @@ class Bridgetown::Site
109
111
  end
110
112
 
111
113
  # Renders a content item while ensuring site locale is set if the data is available.
114
+ #
112
115
  # @param item [Bridgetown::Resource::Base] The item to render
113
116
  # @yield Runs the block in between locale setting and resetting
114
117
  # @return [void]
@@ -28,7 +28,7 @@ class Bridgetown::Site
28
28
 
29
29
  def enable_ssr
30
30
  Bridgetown.logger.info "SSR:", "enabled."
31
- config.fast_refresh = false # SSR mode and Fast Refresh mode are mututally exclusive
31
+ config.fast_refresh = false # SSR mode and Fast Refresh mode are mutually exclusive
32
32
  @ssr_enabled = true
33
33
  end
34
34
 
@@ -45,7 +45,6 @@ class Bridgetown::Site
45
45
  end
46
46
 
47
47
  def ssr_first_read
48
- # TODO: this shouldn't be running twice, right?!
49
48
  Bridgetown::Hooks.trigger :site, :pre_read, self
50
49
  defaults_reader.tap do |d|
51
50
  d.path_defaults.clear
@@ -17,6 +17,7 @@ class Bridgetown::Site
17
17
  write_redirecting_index if config.prefix_default_locale
18
18
 
19
19
  Bridgetown::Hooks.trigger :site, :post_write, self
20
+ Bridgetown.touch_live_reload_file unless config.disable_disk_cache
20
21
  end
21
22
 
22
23
  # Yields all content objects while looping through {#generated_pages},
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bridgetown
4
+ # This mixin for Bridgetown components allows you to provide front matter and render
5
+ # the component template via the layouts transformation pipeline, which can be called
6
+ # from any Roda route
7
+ module Viewable
8
+ include Bridgetown::RodaCallable
9
+ include Bridgetown::Transformable
10
+
11
+ def site
12
+ @site ||= Bridgetown::Current.site
13
+ end
14
+
15
+ def data
16
+ @data ||= HashWithDotAccess::Hash.new
17
+ end
18
+
19
+ def front_matter(&block)
20
+ Bridgetown::FrontMatter::RubyFrontMatter.new(data:).tap { _1.instance_exec(&block) }
21
+ end
22
+
23
+ def relative_path = self.class.source_location.delete_prefix("#{site.root_dir}/")
24
+
25
+ # Render the component template in the layout specified in your front matter
26
+ #
27
+ # @param app [Roda]
28
+ def render_in_layout(app)
29
+ render_in(app) => rendered_output
30
+
31
+ site.validated_layouts_for(self, data.layout).each do |layout|
32
+ transform_with_layout(layout, rendered_output, self) => rendered_output
33
+ end
34
+
35
+ rendered_output
36
+ end
37
+
38
+ # Pass a block of front matter and render the component template in layouts
39
+ #
40
+ # @param app [Roda]
41
+ def render_with(app, &)
42
+ front_matter(&)
43
+ render_in_layout(app)
44
+ end
45
+ end
46
+ end
@@ -111,26 +111,28 @@ module Bridgetown
111
111
  attr_writer :source_manifests, :roda_initializers
112
112
 
113
113
  class << self
114
- # Static: Produce a Configuration ready for use in a Site.
114
+ # Produce a Configuration ready for use in a Site.
115
115
  # It takes the input, fills in the defaults where values do not exist.
116
116
  #
117
- # user_config - a Hash or Configuration of overrides.
118
- #
119
- # Returns a Configuration filled with defaults.
117
+ # @param user_config [Hash, Configuration]
118
+ # @return [Configuration] filled with defaults
120
119
  def from(user_config, starting_defaults = DEFAULTS)
121
120
  Utils.deep_merge_hashes(starting_defaults.deep_dup, Configuration.new(user_config))
122
121
  .merge_environment_specific_options!
123
122
  .setup_load_paths!
124
123
  .setup_locales
125
124
  .add_default_collections
126
- .add_default_excludes
125
+ .add_destination_paths
127
126
  .check_include_exclude
128
127
  end
129
128
  end
130
129
 
131
130
  def run_initializers!(context:) # rubocop:todo Metrics/AbcSize, Metrics/CyclomaticComplexity
132
131
  initializers_file = File.join(root_dir, "config", "initializers.rb")
133
- return unless File.file?(initializers_file)
132
+ unless File.file?(initializers_file)
133
+ setup_load_paths! appending: true
134
+ return
135
+ end
134
136
 
135
137
  load initializers_file
136
138
 
@@ -149,11 +151,15 @@ module Bridgetown
149
151
  dsl._run_builtins!
150
152
  self.url = cached_url if cached_url # restore local development URL if need be
151
153
 
152
- setup_load_paths! appending: true
154
+ setup_post_init!
153
155
 
154
156
  self
155
157
  end
156
158
 
159
+ def setup_post_init!
160
+ add_destination_paths.setup_load_paths! appending: true
161
+ end
162
+
157
163
  # @return [Set<SourceManifest>]
158
164
  def source_manifests
159
165
  @source_manifests ||= Set.new
@@ -177,16 +183,14 @@ module Bridgetown
177
183
  # Directory of the top-level root where config files are located
178
184
  #
179
185
  # @param override [Hash] options hash which will override value if key is present
180
- #
181
186
  # @return [String] path to the Bridgetown root directory
182
187
  def root_dir(override = {})
183
188
  get_config_value_with_override("root_dir", override)
184
189
  end
185
190
 
186
- # Public: Directory of the Bridgetown source folder
191
+ # Directory of the Bridgetown source folder
187
192
  #
188
193
  # @param override [Hash] options hash which will override value if key is present
189
- #
190
194
  # @return [String] path to the Bridgetown source directory
191
195
  def source(override = {})
192
196
  get_config_value_with_override("source", override)
@@ -208,11 +212,10 @@ module Bridgetown
208
212
  raise "Unable to parse `#{File.basename(filename)}'. #{e.message}"
209
213
  end
210
214
 
211
- # Public: Generate list of configuration files from the override
212
- #
213
- # override - the command-line options hash
215
+ # Generate list of configuration files from the override
214
216
  #
215
- # Returns an Array of config files
217
+ # @param override [Hash] the command-line options hash
218
+ # @return [Array<string>] config files
216
219
  def config_files(override)
217
220
  # Adjust verbosity quickly
218
221
  Bridgetown.logger.adjust_verbosity(
@@ -232,9 +235,8 @@ module Bridgetown
232
235
  # Read in a list of configuration files and merge with this hash
233
236
  #
234
237
  # @param files [Array<String>]
235
- #
236
238
  # @return [Hash] configuration with the defaults overridden by the values in the
237
- # configuration files
239
+ # configuration files
238
240
  def read_config_files(files)
239
241
  config = self
240
242
 
@@ -257,7 +259,6 @@ module Bridgetown
257
259
  # Read configuration and return merged Hash
258
260
  #
259
261
  # @param file [String] the path to the YAML file to be read in
260
- #
261
262
  # @return [Hash]
262
263
  def read_config_file(file)
263
264
  default_config_file = file == "bridgetown.config.yml"
@@ -289,13 +290,13 @@ module Bridgetown
289
290
  end
290
291
 
291
292
  def setup_load_paths!(appending: false) # rubocop:todo Metrics
292
- unless appending
293
- self[:root_dir] = File.expand_path(self[:root_dir])
294
- self[:source] = File.expand_path(self[:source], self[:root_dir])
295
- self[:destination] = File.expand_path(self[:destination], self[:root_dir])
293
+ self[:root_dir] = File.expand_path(self[:root_dir])
294
+ self[:source] = File.expand_path(self[:source], self[:root_dir])
295
+ self[:destination] = File.expand_path(self[:destination], self[:root_dir])
296
296
 
297
+ unless appending
297
298
  autoload_paths.unshift({
298
- path: self[:plugins_dir],
299
+ path: File.expand_path(self[:plugins_dir], self[:root_dir]),
299
300
  eager: true,
300
301
  })
301
302
  autoload_paths.unshift({
@@ -363,13 +364,18 @@ module Bridgetown
363
364
  vendor/bundle/ vendor/cache/ vendor/gems/ vendor/ruby/
364
365
  ).freeze
365
366
 
366
- def add_default_excludes
367
+ def add_destination_paths
368
+ self["keep_files"] << "_bridgetown" unless
369
+ self["keep_files"].nil?.! && self["keep_files"].include?("_bridgetown")
370
+
367
371
  return self if self["exclude"].nil?
368
372
 
369
373
  self["exclude"].concat(DEFAULT_EXCLUDES).uniq!
370
374
  self
371
375
  end
372
376
 
377
+ alias_method :add_default_excludes, :add_destination_paths
378
+
373
379
  def should_execute_inline_ruby?
374
380
  ENV["BRIDGETOWN_RUBY_IN_FRONT_MATTER"] != "false" &&
375
381
  self["ruby_in_front_matter"]
@@ -9,7 +9,7 @@ jobs:
9
9
  build:
10
10
  runs-on: ubuntu-latest
11
11
  steps:
12
- - uses: actions/checkout@v2
12
+ - uses: actions/checkout@v4
13
13
 
14
14
  - name: Setup Ruby
15
15
  uses: ruby/setup-ruby@v1
@@ -17,9 +17,9 @@ jobs:
17
17
  bundler-cache: true
18
18
 
19
19
  - name: Setup Node
20
- uses: actions/setup-node@v2
20
+ uses: actions/setup-node@v4
21
21
  with:
22
- node-version: "20"
22
+ node-version: "22"
23
23
  cache: "npm"
24
24
  - run: npm install
25
25
 
@@ -29,7 +29,7 @@ jobs:
29
29
  run: bin/bridgetown deploy
30
30
 
31
31
  - name: Upload build artifact
32
- uses: actions/upload-pages-artifact@v1
32
+ uses: actions/upload-pages-artifact@v3
33
33
  with:
34
34
  path: ./output
35
35
 
@@ -48,4 +48,4 @@ jobs:
48
48
  steps:
49
49
  - name: Deploy to GitHub Pages
50
50
  id: deployment
51
- uses: actions/deploy-pages@v1
51
+ uses: actions/deploy-pages@v4