bridgetown-core 0.13.0 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/bin/bridgetown +0 -25
  3. data/bridgetown-core.gemspec +4 -1
  4. data/lib/bridgetown-core.rb +4 -1
  5. data/lib/bridgetown-core/cleaner.rb +1 -0
  6. data/lib/bridgetown-core/command.rb +10 -4
  7. data/lib/bridgetown-core/commands/console.rb +1 -2
  8. data/lib/bridgetown-core/commands/doctor.rb +1 -2
  9. data/lib/bridgetown-core/commands/new.rb +0 -3
  10. data/lib/bridgetown-core/commands/plugins.rb +169 -0
  11. data/lib/bridgetown-core/{convertible.rb → concerns/convertible.rb} +2 -2
  12. data/lib/bridgetown-core/concerns/site/configurable.rb +153 -0
  13. data/lib/bridgetown-core/concerns/site/content.rb +111 -0
  14. data/lib/bridgetown-core/concerns/site/extensible.rb +56 -0
  15. data/lib/bridgetown-core/concerns/site/processable.rb +74 -0
  16. data/lib/bridgetown-core/concerns/site/renderable.rb +50 -0
  17. data/lib/bridgetown-core/concerns/site/writable.rb +31 -0
  18. data/lib/bridgetown-core/configuration.rb +2 -9
  19. data/lib/bridgetown-core/converters/markdown/kramdown_parser.rb +0 -3
  20. data/lib/bridgetown-core/document.rb +1 -1
  21. data/lib/bridgetown-core/drops/site_drop.rb +1 -1
  22. data/lib/bridgetown-core/external.rb +17 -21
  23. data/lib/bridgetown-core/filters.rb +10 -0
  24. data/lib/bridgetown-core/generators/prototype_generator.rb +1 -1
  25. data/lib/bridgetown-core/hooks.rb +62 -62
  26. data/lib/bridgetown-core/layout.rb +10 -4
  27. data/lib/bridgetown-core/page.rb +9 -2
  28. data/lib/bridgetown-core/plugin.rb +2 -0
  29. data/lib/bridgetown-core/plugin_manager.rb +62 -12
  30. data/lib/bridgetown-core/reader.rb +5 -0
  31. data/lib/bridgetown-core/readers/data_reader.rb +5 -2
  32. data/lib/bridgetown-core/readers/layout_reader.rb +9 -2
  33. data/lib/bridgetown-core/readers/plugin_content_reader.rb +48 -0
  34. data/lib/bridgetown-core/renderer.rb +7 -10
  35. data/lib/bridgetown-core/site.rb +20 -463
  36. data/lib/bridgetown-core/utils.rb +1 -27
  37. data/lib/bridgetown-core/utils/ruby_exec.rb +1 -4
  38. data/lib/bridgetown-core/version.rb +2 -2
  39. data/lib/bridgetown-core/watcher.rb +5 -1
  40. data/lib/site_template/plugins/{.keep → builders/.keep} +0 -0
  41. data/lib/site_template/plugins/site_builder.rb +4 -0
  42. data/lib/site_template/src/_includes/navbar.html +1 -0
  43. data/lib/site_template/src/posts.md +15 -0
  44. data/lib/site_template/start.js +1 -1
  45. metadata +58 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5434399f502bf037e77a019dfda4b2deae10b6a532349ec21b32977a224ca448
4
- data.tar.gz: cae6a4eb2d435bfd0e85f18320e76a90619c872ccf69f44c9ac2e13e987e1fe7
3
+ metadata.gz: d2c8f263d4104e1dc79885d0ecb19226a5b504518af3c43cb48c9e8da90fe971
4
+ data.tar.gz: b52e7a958ea715407c689c492365e44de88cd42ed0193be58f4acaed00efd58d
5
5
  SHA512:
6
- metadata.gz: 5344308e24f519099a33af769a1c5dd908d1fd54f10aaec4c81f4254c9ff772787f1a2e4b9f0d488a21167cc98c6a1c526df1fd2e7d6ee4e86cf33afc4efe2bd
7
- data.tar.gz: f2eedc957c8782b03e08f0834b88981e40f6539ac65899096bcfc1c1e4ed196b4046859530d5e281dee2b1455ac4e01e7b8a63dfdf29e3ad36e8725d1ed00f64
6
+ metadata.gz: ef77c2319ef1a31cbc9a4a00c6bbfcfc148d662f97b18b337d094f8bb473ea16ad61ccc5bcc0a16070db5beea331a48754c0ef83e2841e804f598cb6e052c420
7
+ data.tar.gz: 22727baee9961e123388a683eac0d03fb9db6b0dece4cdb1c5e2515d022eb12c4c7ad3f7d34116bb7548691d955febc86d7d174be9482ff6db1dcceda5153040
@@ -17,31 +17,6 @@ Mercenary.program(:bridgetown) do |p|
17
17
  p.description "Bridgetown is a Webpack-aware, Ruby-powered static site generator for the modern Jamstack era"
18
18
  p.syntax "bridgetown <subcommand> [options]"
19
19
 
20
- # TODO: it seems wonky to include build options in this top-level
21
- # exe. Should probably remove most things here and relocated to
22
- # individual comments. …in fact there are duplicate option listings
23
- # if you do bridgetown build --help — ouch!
24
- p.option "source", "-s", "--source [DIR]", "Source directory (defaults to src)"
25
- p.option "destination", "-d", "--destination [DIR]",
26
- "Destination directory (defaults to output)"
27
- p.option "plugins_dir", "-p", "--plugins PLUGINS_DIR1[,PLUGINS_DIR2[,...]]", Array,
28
- "Plugins directory (defaults to plugins)"
29
- p.option "layouts_dir", "--layouts DIR", String,
30
- "Layouts directory (defaults to src/_layouts)"
31
- p.option "profile", "--profile", "Generate a Liquid rendering profile"
32
-
33
- # TODO: this is not the way to bring in extra command gems!
34
- # Bridgetown::External.require_if_present(Bridgetown::External.blessed_gems) do |g, ver_constraint|
35
- # cmd = g.split("-").last
36
- # p.command(cmd.to_sym) do |c|
37
- # c.syntax cmd
38
- # c.action do
39
- # Bridgetown.logger.abort_with "You must install the '#{g}' gem" \
40
- # " version #{ver_constraint} to use the 'bridgetown #{cmd}' command."
41
- # end
42
- # end
43
- # end
44
-
45
20
  Bridgetown::Command.subclasses.each { |c| c.init_with_program(p) }
46
21
 
47
22
  p.action do |args, _|
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
8
8
  s.license = "MIT"
9
9
  s.author = "Bridgetown Team"
10
10
  s.email = "maintainers@bridgetownrb.com"
11
- s.homepage = "https://bridgetownrb.com"
11
+ s.homepage = "https://www.bridgetownrb.com"
12
12
  s.summary = "A Webpack-aware, Ruby-based static site generator for the modern Jamstack era"
13
13
  s.description = "Bridgetown is a Webpack-aware, Ruby-powered static site generator for the modern Jamstack era"
14
14
 
@@ -31,13 +31,16 @@ Gem::Specification.new do |s|
31
31
  s.required_ruby_version = ">= 2.5.0"
32
32
  s.required_rubygems_version = ">= 2.7.0"
33
33
 
34
+ s.add_runtime_dependency("activesupport", "~> 6.0")
34
35
  s.add_runtime_dependency("addressable", "~> 2.4")
35
36
  s.add_runtime_dependency("colorator", "~> 1.0")
36
37
  s.add_runtime_dependency("faraday", "~> 1.0")
38
+ s.add_runtime_dependency("faraday_middleware", "~> 1.0")
37
39
  s.add_runtime_dependency("i18n", "~> 1.0")
38
40
  s.add_runtime_dependency("kramdown", "~> 2.1")
39
41
  s.add_runtime_dependency("kramdown-parser-gfm", "~> 1.0")
40
42
  s.add_runtime_dependency("liquid", "~> 4.0")
43
+ s.add_runtime_dependency("liquid-render-tag", "~> 0.2")
41
44
  s.add_runtime_dependency("listen", "~> 3.0")
42
45
  s.add_runtime_dependency("mercenary", "~> 0.4.0")
43
46
  s.add_runtime_dependency("pathutil", "~> 0.9")
@@ -29,10 +29,12 @@ require "csv"
29
29
  require "json"
30
30
 
31
31
  # 3rd party
32
+ require "active_support/core_ext/hash/indifferent_access"
32
33
  require "pathutil"
33
34
  require "addressable/uri"
34
35
  require "safe_yaml/load"
35
36
  require "liquid"
37
+ require "liquid-render-tag"
36
38
  require "kramdown"
37
39
  require "colorator"
38
40
  require "i18n"
@@ -49,7 +51,7 @@ module Bridgetown
49
51
  autoload :Cleaner, "bridgetown-core/cleaner"
50
52
  autoload :Collection, "bridgetown-core/collection"
51
53
  autoload :Configuration, "bridgetown-core/configuration"
52
- autoload :Convertible, "bridgetown-core/convertible"
54
+ autoload :Convertible, "bridgetown-core/concerns/convertible"
53
55
  autoload :Deprecator, "bridgetown-core/deprecator"
54
56
  autoload :Document, "bridgetown-core/document"
55
57
  autoload :EntryFilter, "bridgetown-core/entry_filter"
@@ -65,6 +67,7 @@ module Bridgetown
65
67
  autoload :LayoutReader, "bridgetown-core/readers/layout_reader"
66
68
  autoload :PostReader, "bridgetown-core/readers/post_reader"
67
69
  autoload :PageReader, "bridgetown-core/readers/page_reader"
70
+ autoload :PluginContentReader, "bridgetown-core/readers/plugin_content_reader"
68
71
  autoload :StaticFileReader, "bridgetown-core/readers/static_file_reader"
69
72
  autoload :LogAdapter, "bridgetown-core/log_adapter"
70
73
  autoload :Page, "bridgetown-core/page"
@@ -24,6 +24,7 @@ module Bridgetown
24
24
  def obsolete_files
25
25
  out = (existing_files - new_files - new_dirs + replaced_files).to_a
26
26
  Bridgetown::Hooks.trigger :clean, :on_obsolete, out
27
+ @new_files = @new_dirs = nil
27
28
  out
28
29
  end
29
30
 
@@ -53,11 +53,16 @@ module Bridgetown
53
53
  def add_build_options(cmd)
54
54
  cmd.option "config", "--config CONFIG_FILE[,CONFIG_FILE2,...]",
55
55
  Array, "Custom configuration file"
56
- cmd.option "destination", "-d", "--destination DESTINATION",
57
- "The current folder will be generated into DESTINATION"
58
- cmd.option "root_dir", "-r", "--root_dir ROOT_DIR", "The top-level root folder" \
56
+ cmd.option "source", "-s", "--source [DIR]",
57
+ "Source directory (defaults to src)"
58
+ cmd.option "destination", "-d", "--destination [DIR]",
59
+ "Destination directory (defaults to output)"
60
+ cmd.option "root_dir", "-r", "--root_dir [DIR]", "The top-level root folder" \
59
61
  " where config files are located"
60
- cmd.option "source", "-s", "--source SOURCE", "Custom source directory"
62
+ cmd.option "plugins_dir", "-p", "--plugins PLUGINS_DIR1[,PLUGINS_DIR2[,...]]", Array,
63
+ "Plugins directory (defaults to plugins)"
64
+ cmd.option "layouts_dir", "--layouts [DIR]", String,
65
+ "Layouts directory (defaults to src/_layouts)"
61
66
  cmd.option "future", "--future", "Publishes posts with a future date"
62
67
  cmd.option "limit_posts", "--limit_posts MAX_POSTS", Integer,
63
68
  "Limits the number of posts to parse and publish"
@@ -70,6 +75,7 @@ module Bridgetown
70
75
  "Render posts that were marked as unpublished"
71
76
  cmd.option "disable_disk_cache", "--disable-disk-cache",
72
77
  "Disable caching to disk"
78
+ cmd.option "profile", "--profile", "Generate a Liquid rendering profile"
73
79
  cmd.option "quiet", "-q", "--quiet", "Silence output."
74
80
  cmd.option "verbose", "-V", "--verbose", "Print verbose output."
75
81
  cmd.option "incremental", "-I", "--incremental", "Enable incremental rebuild."
@@ -12,8 +12,7 @@ module Bridgetown
12
12
  c.description "Invoke an IRB console with the site loaded"
13
13
  c.alias :c
14
14
 
15
- c.option "config", "--config CONFIG_FILE[,CONFIG_FILE2,...]", Array,
16
- "Custom configuration file"
15
+ add_build_options(c)
17
16
 
18
17
  c.action do |_, options|
19
18
  Bridgetown::Commands::Console.process(options)
@@ -9,8 +9,7 @@ module Bridgetown
9
9
  c.syntax "doctor"
10
10
  c.description "Search site and print specific deprecation warnings"
11
11
 
12
- c.option "config", "--config CONFIG_FILE[,CONFIG_FILE2,...]", Array,
13
- "Custom configuration file"
12
+ add_build_options(c)
14
13
 
15
14
  c.action do |_, options|
16
15
  Bridgetown::Commands::Doctor.process(options)
@@ -72,9 +72,6 @@ module Bridgetown
72
72
  #
73
73
  # Happy Bridgetowning!
74
74
 
75
- # Pull in latest Liquid from Shopify with new Render tag
76
- gem 'liquid', "> 4.0.3", github: "jaredcwhite/liquid"
77
-
78
75
  gem "bridgetown", "~> #{Bridgetown::VERSION}"
79
76
 
80
77
  RUBY
@@ -0,0 +1,169 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bridgetown
4
+ module Commands
5
+ class Plugins < Command
6
+ class << self
7
+ def init_with_program(prog)
8
+ plugins_cmd = prog.command(:plugins) do |c|
9
+ c.syntax "plugins <subcommand>"
10
+ c.description "List installed plugins or access plugin content"
11
+
12
+ c.option "config", "--config CONFIG_FILE[,CONFIG_FILE2,...]", Array,
13
+ "Custom configuration file"
14
+
15
+ c.action do
16
+ output_supercommand_syntax(c)
17
+ end
18
+ end
19
+
20
+ plugins_cmd.command(:list) do |subcmd|
21
+ subcmd.syntax "list"
22
+ subcmd.description "List information about installed plugins"
23
+
24
+ subcmd.action do |_, options|
25
+ list(options)
26
+ end
27
+ end
28
+
29
+ plugins_cmd.command(:cd) do |subcmd|
30
+ subcmd.syntax "cd <origin/dir>"
31
+ subcmd.description "Open directory (content, layouts, etc.) within the plugin origin"
32
+
33
+ subcmd.action do |args, options|
34
+ if args.empty?
35
+ puts subcmd.to_s
36
+ else
37
+ cd(args, options)
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ def output_supercommand_syntax(supercmd)
44
+ puts supercmd.to_s
45
+ end
46
+
47
+ def list(options)
48
+ site = Bridgetown::Site.new(configuration_from_options(options))
49
+ site.reset
50
+ Bridgetown::Hooks.trigger :site, :pre_read, site
51
+
52
+ pm = site.plugin_manager
53
+
54
+ plugins_list = pm.class.registered_plugins.reject do |plugin|
55
+ plugin.to_s.end_with? "site_builder.rb"
56
+ end
57
+
58
+ Bridgetown.logger.info("Registered Plugins:", plugins_list.length.to_s.yellow.bold)
59
+
60
+ plugins_list.each do |plugin|
61
+ unless plugin.to_s.end_with? "site_builder.rb"
62
+ Bridgetown.logger.info("", plugin.to_s.sub(site.in_root_dir("/"), ""))
63
+ end
64
+ end
65
+
66
+ Bridgetown.logger.info("Source Manifests:", "---") unless pm.class.source_manifests.empty?
67
+
68
+ pm.class.source_manifests.each do |manifest|
69
+ Bridgetown.logger.info("Origin:", (manifest.origin || "n/a").to_s.green)
70
+ Bridgetown.logger.info("Components:", (manifest.components || "n/a").to_s.cyan)
71
+ Bridgetown.logger.info("Content:", (manifest.content || "n/a").to_s.cyan)
72
+ Bridgetown.logger.info("Layouts:", (manifest.layouts || "n/a").to_s.cyan)
73
+
74
+ Bridgetown.logger.info("", "---")
75
+ end
76
+
77
+ unless Bridgetown.autoload? :Builder
78
+ builders = Bridgetown::Builder.descendants
79
+ Bridgetown.logger.info("Builders:", builders.length.to_s.yellow.bold)
80
+
81
+ builders.each do |builder|
82
+ name = builder.respond_to?(:custom_name) ? builder.custom_name : builder.name
83
+ name_components = name.split("::")
84
+ last_name = name_components.pop
85
+ name_components.push last_name.magenta
86
+ Bridgetown.logger.info("", name_components.join("::"))
87
+ end
88
+ end
89
+
90
+ Bridgetown.logger.info("Converters:", site.converters.length.to_s.yellow.bold)
91
+
92
+ site.converters.each do |converter|
93
+ name = plugin_name_for(converter)
94
+ name_components = name.split("::")
95
+ last_name = name_components.pop
96
+ name_components.push last_name.magenta
97
+ Bridgetown.logger.info("", name_components.join("::"))
98
+ end
99
+
100
+ Bridgetown.logger.info("Generators:", site.generators.length.to_s.yellow.bold)
101
+
102
+ site.generators.each do |generator|
103
+ name = plugin_name_for(generator)
104
+ name_components = name.split("::")
105
+ last_name = name_components.pop
106
+ name_components.push last_name.magenta
107
+ Bridgetown.logger.info("", name_components.join("::"))
108
+ end
109
+ end
110
+
111
+ # This is super useful if you want to copy files out of plugins to override.
112
+ #
113
+ # Example:
114
+ # bridgetown plugins cd AwesomePlugin/layouts
115
+ # cp -r * $BRIDGETOWN_SITE/src/_layouts
116
+ #
117
+ # Now all the plugin's layouts will be in the site repo directly.
118
+ #
119
+ def cd(args, options)
120
+ site = Bridgetown::Site.new(configuration_from_options(options))
121
+
122
+ pm = site.plugin_manager
123
+
124
+ directive = args[0].split("/")
125
+ unless directive[1]
126
+ Bridgetown.logger.warn("Oops!", "Your command needs to be in the <origin/dir> format")
127
+ return
128
+ end
129
+
130
+ manifest = pm.class.source_manifests.find do |source_manifest|
131
+ source_manifest.origin.to_s == directive[0]
132
+ end
133
+
134
+ if manifest&.respond_to?(directive[1].downcase)
135
+ dir = manifest.send(directive[1].downcase)
136
+ Bridgetown.logger.info("Opening the #{dir.green} folder for" \
137
+ " #{manifest.origin.to_s.cyan}…")
138
+ Bridgetown.logger.info("Type #{"exit".yellow} when you're done to" \
139
+ " return to your site root.")
140
+ puts
141
+
142
+ Dir.chdir dir do
143
+ ENV["BRIDGETOWN_SITE"] = site.root_dir
144
+ if ENV["SHELL"]
145
+ system(ENV["SHELL"])
146
+ else
147
+ system("/bin/sh")
148
+ end
149
+ end
150
+
151
+ puts
152
+ Bridgetown.logger.info("Done!", "You're back in #{Dir.pwd.green}")
153
+ else
154
+ Bridgetown.logger.warn("Oops!", "I wasn't able to find the" \
155
+ " #{directive[1]} folder for #{directive[0]}")
156
+ end
157
+ end
158
+
159
+ def plugin_name_for(plugin)
160
+ if plugin.class.respond_to?(:custom_name)
161
+ plugin.class.custom_name
162
+ else
163
+ plugin.class.name
164
+ end
165
+ end
166
+ end
167
+ end
168
+ end
169
+ end
@@ -42,7 +42,7 @@ module Bridgetown
42
42
  **Utils.merged_file_read_opts(site, opts))
43
43
  if content =~ Document::YAML_FRONT_MATTER_REGEXP
44
44
  self.content = $POSTMATCH
45
- self.data = SafeYAML.load(Regexp.last_match(1))
45
+ self.data = SafeYAML.load(Regexp.last_match(1))&.with_indifferent_access
46
46
  end
47
47
  rescue Psych::SyntaxError => e
48
48
  Bridgetown.logger.warn "YAML Exception reading #{filename}: #{e.message}"
@@ -52,7 +52,7 @@ module Bridgetown
52
52
  raise e if site.config["strict_front_matter"]
53
53
  end
54
54
 
55
- self.data ||= {}
55
+ self.data ||= ActiveSupport::HashWithIndifferentAccess.new
56
56
 
57
57
  validate_data! filename
58
58
  validate_permalink! filename
@@ -0,0 +1,153 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bridgetown
4
+ module Site::Configurable
5
+ # Public: Set the site's configuration. This handles side-effects caused by
6
+ # changing values in the configuration.
7
+ #
8
+ # config - a Bridgetown::Configuration, containing the new configuration.
9
+ #
10
+ # Returns the new configuration.
11
+ def config=(config)
12
+ @config = config.clone
13
+
14
+ # Source and destination may not be changed after the site has been created.
15
+ @root_dir = File.expand_path(config["root_dir"]).freeze
16
+ @source = File.expand_path(config["source"]).freeze
17
+ @dest = File.expand_path(config["destination"]).freeze
18
+ @cache_dir = in_root_dir(config["cache_dir"]).freeze
19
+
20
+ %w(lsi highlighter baseurl exclude include future unpublished
21
+ limit_posts keep_files).each do |opt|
22
+ send("#{opt}=", config[opt])
23
+ end
24
+
25
+ configure_cache
26
+ configure_component_paths
27
+ configure_include_paths
28
+ configure_file_read_opts
29
+
30
+ self.permalink_style = config["permalink"].to_sym
31
+
32
+ @config
33
+ end
34
+
35
+ # Returns the FrontmatterDefaults or creates a new FrontmatterDefaults
36
+ # if it doesn't already exist.
37
+ #
38
+ # Returns The FrontmatterDefaults
39
+ def frontmatter_defaults
40
+ @frontmatter_defaults ||= FrontmatterDefaults.new(self)
41
+ end
42
+
43
+ # Whether to perform a full rebuild without incremental regeneration
44
+ #
45
+ # Returns a Boolean: true for a full rebuild, false for normal build
46
+ def incremental?(override = {})
47
+ override["incremental"] || config["incremental"]
48
+ end
49
+
50
+ # Returns the publisher or creates a new publisher if it doesn't
51
+ # already exist.
52
+ #
53
+ # Returns The Publisher
54
+ def publisher
55
+ @publisher ||= Publisher.new(self)
56
+ end
57
+
58
+ # Public: Prefix a given path with the root directory.
59
+ #
60
+ # paths - (optional) path elements to a file or directory within the
61
+ # root directory
62
+ #
63
+ # Returns a path which is prefixed with the root_dir directory.
64
+ def in_root_dir(*paths)
65
+ paths.reduce(root_dir) do |base, path|
66
+ Bridgetown.sanitized_path(base, path)
67
+ end
68
+ end
69
+
70
+ # Public: Prefix a given path with the source directory.
71
+ #
72
+ # paths - (optional) path elements to a file or directory within the
73
+ # source directory
74
+ #
75
+ # Returns a path which is prefixed with the source directory.
76
+ def in_source_dir(*paths)
77
+ paths.reduce(source) do |base, path|
78
+ Bridgetown.sanitized_path(base, path)
79
+ end
80
+ end
81
+
82
+ # Public: Prefix a given path with the destination directory.
83
+ #
84
+ # paths - (optional) path elements to a file or directory within the
85
+ # destination directory
86
+ #
87
+ # Returns a path which is prefixed with the destination directory.
88
+ def in_dest_dir(*paths)
89
+ paths.reduce(dest) do |base, path|
90
+ Bridgetown.sanitized_path(base, path)
91
+ end
92
+ end
93
+
94
+ # Public: Prefix a given path with the cache directory.
95
+ #
96
+ # paths - (optional) path elements to a file or directory within the
97
+ # cache directory
98
+ #
99
+ # Returns a path which is prefixed with the cache directory.
100
+ def in_cache_dir(*paths)
101
+ paths.reduce(cache_dir) do |base, path|
102
+ Bridgetown.sanitized_path(base, path)
103
+ end
104
+ end
105
+
106
+ # Public: The full path to the directory that houses all the collections registered
107
+ # with the current site.
108
+ #
109
+ # Returns the source directory or the absolute path to the custom collections_dir
110
+ def collections_path
111
+ dir_str = config["collections_dir"]
112
+ @collections_path ||= dir_str.empty? ? source : in_source_dir(dir_str)
113
+ end
114
+
115
+ private
116
+
117
+ # Disable Marshaling cache to disk in Safe Mode
118
+ def configure_cache
119
+ Bridgetown::Cache.cache_dir = in_root_dir(config["cache_dir"], "Bridgetown/Cache")
120
+ Bridgetown::Cache.disable_disk_cache! if config["disable_disk_cache"]
121
+ end
122
+
123
+ def configure_component_paths
124
+ # Loop through plugins paths first
125
+ plugin_components_load_paths = Bridgetown::PluginManager.source_manifests
126
+ .map(&:components).compact
127
+
128
+ local_components_load_paths = config["components_dir"].yield_self do |dir|
129
+ dir.is_a?(Array) ? dir : [dir]
130
+ end
131
+ local_components_load_paths.map! do |dir|
132
+ if !!(dir =~ %r!^\.\.?\/!)
133
+ # allow ./dir or ../../dir type options
134
+ File.expand_path(dir.to_s, root_dir)
135
+ else
136
+ in_source_dir(dir.to_s)
137
+ end
138
+ end
139
+
140
+ @components_load_paths = plugin_components_load_paths + local_components_load_paths
141
+ end
142
+
143
+ def configure_include_paths
144
+ @includes_load_paths = Array(in_source_dir(config["includes_dir"].to_s))
145
+ end
146
+
147
+ def configure_file_read_opts
148
+ self.file_read_opts = {}
149
+ file_read_opts[:encoding] = config["encoding"] if config["encoding"]
150
+ self.file_read_opts = Bridgetown::Utils.merged_file_read_opts(self, {})
151
+ end
152
+ end
153
+ end