bridgetown-core 0.19.3 → 0.21.0.beta4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/bridgetown-core.gemspec +1 -2
  3. data/lib/bridgetown-core.rb +37 -29
  4. data/lib/bridgetown-core/cleaner.rb +9 -3
  5. data/lib/bridgetown-core/collection.rb +177 -78
  6. data/lib/bridgetown-core/commands/base.rb +9 -0
  7. data/lib/bridgetown-core/commands/build.rb +0 -11
  8. data/lib/bridgetown-core/commands/concerns/git_helpers.rb +20 -0
  9. data/lib/bridgetown-core/commands/configure.rb +8 -3
  10. data/lib/bridgetown-core/commands/console.rb +4 -0
  11. data/lib/bridgetown-core/commands/doctor.rb +1 -19
  12. data/lib/bridgetown-core/commands/new.rb +6 -6
  13. data/lib/bridgetown-core/commands/plugins.rb +14 -13
  14. data/lib/bridgetown-core/commands/serve.rb +0 -14
  15. data/lib/bridgetown-core/commands/webpack.rb +75 -0
  16. data/lib/bridgetown-core/commands/webpack/enable-postcss.rb +12 -0
  17. data/lib/bridgetown-core/commands/webpack/setup.rb +4 -0
  18. data/lib/bridgetown-core/commands/webpack/update.rb +3 -0
  19. data/lib/bridgetown-core/commands/webpack/webpack.config.js +18 -0
  20. data/lib/{site_template/webpack.config.js.erb → bridgetown-core/commands/webpack/webpack.defaults.js.erb} +32 -16
  21. data/lib/bridgetown-core/component.rb +183 -0
  22. data/lib/bridgetown-core/concerns/data_accessible.rb +1 -0
  23. data/lib/bridgetown-core/concerns/front_matter_importer.rb +52 -0
  24. data/lib/bridgetown-core/concerns/layout_placeable.rb +1 -1
  25. data/lib/bridgetown-core/concerns/site/configurable.rb +10 -10
  26. data/lib/bridgetown-core/concerns/site/content.rb +56 -15
  27. data/lib/bridgetown-core/concerns/site/localizable.rb +3 -5
  28. data/lib/bridgetown-core/concerns/site/processable.rb +6 -4
  29. data/lib/bridgetown-core/concerns/site/renderable.rb +26 -0
  30. data/lib/bridgetown-core/concerns/site/writable.rb +12 -2
  31. data/lib/bridgetown-core/concerns/validatable.rb +2 -5
  32. data/lib/bridgetown-core/configuration.rb +61 -33
  33. data/lib/bridgetown-core/configurations/bt-postcss.rb +6 -6
  34. data/lib/bridgetown-core/configurations/netlify.rb +1 -0
  35. data/lib/bridgetown-core/configurations/tailwindcss.rb +6 -6
  36. data/lib/bridgetown-core/converter.rb +23 -0
  37. data/lib/bridgetown-core/converters/erb_templates.rb +51 -35
  38. data/lib/bridgetown-core/converters/identity.rb +0 -9
  39. data/lib/bridgetown-core/converters/liquid_templates.rb +1 -1
  40. data/lib/bridgetown-core/converters/markdown.rb +14 -4
  41. data/lib/bridgetown-core/converters/markdown/kramdown_parser.rb +5 -38
  42. data/lib/bridgetown-core/converters/ruby_templates.rb +17 -0
  43. data/lib/bridgetown-core/converters/smartypants.rb +3 -1
  44. data/lib/bridgetown-core/core_ext/psych.rb +19 -0
  45. data/lib/bridgetown-core/current.rb +10 -0
  46. data/lib/bridgetown-core/document.rb +9 -16
  47. data/lib/bridgetown-core/drops/collection_drop.rb +1 -1
  48. data/lib/bridgetown-core/drops/page_drop.rb +4 -0
  49. data/lib/bridgetown-core/drops/relations_drop.rb +23 -0
  50. data/lib/bridgetown-core/drops/resource_drop.rb +83 -0
  51. data/lib/bridgetown-core/drops/site_drop.rb +33 -8
  52. data/lib/bridgetown-core/drops/unified_payload_drop.rb +5 -0
  53. data/lib/bridgetown-core/entry_filter.rb +17 -28
  54. data/lib/bridgetown-core/errors.rb +0 -2
  55. data/lib/bridgetown-core/filters.rb +3 -26
  56. data/lib/bridgetown-core/filters/from_liquid.rb +23 -0
  57. data/lib/bridgetown-core/filters/url_filters.rb +12 -0
  58. data/lib/bridgetown-core/frontmatter_defaults.rb +1 -1
  59. data/lib/bridgetown-core/generators/prototype_generator.rb +59 -20
  60. data/lib/bridgetown-core/helpers.rb +48 -9
  61. data/lib/bridgetown-core/layout.rb +53 -21
  62. data/lib/bridgetown-core/liquid_renderer/file.rb +1 -0
  63. data/lib/bridgetown-core/liquid_renderer/table.rb +1 -0
  64. data/lib/bridgetown-core/model/base.rb +138 -0
  65. data/lib/bridgetown-core/model/builder_origin.rb +40 -0
  66. data/lib/bridgetown-core/model/origin.rb +38 -0
  67. data/lib/bridgetown-core/model/repo_origin.rb +126 -0
  68. data/lib/bridgetown-core/page.rb +11 -2
  69. data/lib/bridgetown-core/plugin_manager.rb +1 -3
  70. data/lib/bridgetown-core/publisher.rb +8 -2
  71. data/lib/bridgetown-core/reader.rb +37 -22
  72. data/lib/bridgetown-core/readers/data_reader.rb +5 -5
  73. data/lib/bridgetown-core/readers/defaults_reader.rb +1 -1
  74. data/lib/bridgetown-core/readers/layout_reader.rb +1 -1
  75. data/lib/bridgetown-core/readers/page_reader.rb +1 -0
  76. data/lib/bridgetown-core/readers/post_reader.rb +5 -4
  77. data/lib/bridgetown-core/regenerator.rb +9 -2
  78. data/lib/bridgetown-core/related_posts.rb +9 -6
  79. data/lib/bridgetown-core/renderer.rb +6 -13
  80. data/lib/bridgetown-core/resource/base.rb +329 -0
  81. data/lib/bridgetown-core/resource/destination.rb +49 -0
  82. data/lib/bridgetown-core/resource/permalink_processor.rb +179 -0
  83. data/lib/bridgetown-core/resource/relations.rb +132 -0
  84. data/lib/bridgetown-core/resource/taxonomy_term.rb +34 -0
  85. data/lib/bridgetown-core/resource/taxonomy_type.rb +56 -0
  86. data/lib/bridgetown-core/resource/transformer.rb +177 -0
  87. data/lib/bridgetown-core/ruby_template_view.rb +11 -11
  88. data/lib/bridgetown-core/site.rb +13 -6
  89. data/lib/bridgetown-core/static_file.rb +33 -10
  90. data/lib/bridgetown-core/tags/highlight.rb +2 -15
  91. data/lib/bridgetown-core/tags/include.rb +1 -1
  92. data/lib/bridgetown-core/tags/post_url.rb +2 -2
  93. data/lib/bridgetown-core/url.rb +1 -0
  94. data/lib/bridgetown-core/utils.rb +49 -43
  95. data/lib/bridgetown-core/utils/require_gems.rb +60 -0
  96. data/lib/bridgetown-core/utils/ruby_exec.rb +6 -9
  97. data/lib/bridgetown-core/utils/ruby_front_matter.rb +39 -0
  98. data/lib/bridgetown-core/version.rb +2 -2
  99. data/lib/bridgetown-core/watcher.rb +2 -1
  100. data/lib/bridgetown-core/yaml_parser.rb +22 -0
  101. data/lib/site_template/config/.keep +0 -0
  102. data/lib/site_template/package.json.erb +4 -4
  103. data/lib/site_template/plugins/site_builder.rb +1 -1
  104. data/lib/site_template/src/_posts/0000-00-00-welcome-to-bridgetown.md.erb +1 -1
  105. metadata +46 -41
  106. data/lib/bridgetown-core/external.rb +0 -58
  107. data/lib/bridgetown-core/page_without_a_file.rb +0 -17
  108. data/lib/bridgetown-core/path_manager.rb +0 -31
  109. data/lib/bridgetown-core/readers/collection_reader.rb +0 -23
  110. data/lib/bridgetown-core/readers/static_file_reader.rb +0 -25
  111. data/lib/bridgetown-core/utils/exec.rb +0 -26
  112. data/lib/bridgetown-core/utils/internet.rb +0 -37
  113. data/lib/bridgetown-core/utils/platforms.rb +0 -80
  114. data/lib/bridgetown-core/utils/thread_event.rb +0 -31
  115. data/lib/bridgetown-core/utils/win_tz.rb +0 -75
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bridgetown
4
+ # TODO: to be retired once the Resource engine is made official
4
5
  class Page
5
6
  include DataAccessible
6
7
  include LayoutPlaceable
@@ -44,10 +45,10 @@ module Bridgetown
44
45
  end
45
46
 
46
47
  process(name)
47
- read_yaml(PathManager.join(base, dir), name)
48
+ read_yaml(File.join(base, dir), name)
48
49
 
49
50
  data.default_proc = proc do |_, key|
50
- site.frontmatter_defaults.find(relative_path, type, key)
51
+ site.frontmatter_defaults.find(relative_path, type, key.to_s)
51
52
  end
52
53
 
53
54
  Bridgetown::Hooks.trigger :pages, :post_init, self
@@ -116,6 +117,7 @@ module Bridgetown
116
117
  permalink: permalink
117
118
  ).to_s
118
119
  end
120
+ alias_method :relative_url, :url
119
121
 
120
122
  # Returns a hash of URL placeholder names (as symbols) mapping to the
121
123
  # desired placeholder replacements. For details see "url.rb"
@@ -218,4 +220,11 @@ module Bridgetown
218
220
  true
219
221
  end
220
222
  end
223
+
224
+ # set up virtual page class for future compatibility
225
+ class GeneratedPage < Page
226
+ def read_yaml(_base, _name, _opts = {})
227
+ self.data ||= HashWithDotAccess::Hash.new
228
+ end
229
+ end
221
230
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "zeitwerk"
4
-
5
3
  module Bridgetown
6
4
  class PluginManager
7
5
  PLUGINS_GROUP = :bridgetown_plugins
@@ -135,7 +133,7 @@ module Bridgetown
135
133
  sorted_plugin_files.each do |plugin_file|
136
134
  self.class.add_registered_plugin plugin_file
137
135
  end
138
- Bridgetown::External.require_with_graceful_fail(sorted_plugin_files)
136
+ Bridgetown::Utils::RequireGems.require_with_graceful_fail(sorted_plugin_files)
139
137
  end
140
138
  end
141
139
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  module Bridgetown
4
4
  class Publisher
5
+ # @param site [Bridgetown::Site]
5
6
  def initialize(site)
6
7
  @site = site
7
8
  end
@@ -11,13 +12,18 @@ module Bridgetown
11
12
  end
12
13
 
13
14
  def hidden_in_the_future?(thing)
14
- thing.respond_to?(:date) && !@site.future && thing.date.to_i > @site.time.to_i
15
+ return false unless thing.respond_to?(:date)
16
+
17
+ future_allowed =
18
+ thing.respond_to?(:collection) && thing.collection.metadata.future || @site.config.future
19
+ thing_time = thing.date.is_a?(Date) ? thing.date.to_time.to_i : thing.date.to_i
20
+ !future_allowed && thing_time > @site.time.to_i
15
21
  end
16
22
 
17
23
  private
18
24
 
19
25
  def can_be_published?(thing)
20
- thing.data.fetch("published", true) || @site.unpublished
26
+ thing.data.fetch("published", true) || @site.config.unpublished
21
27
  end
22
28
  end
23
29
  end
@@ -11,20 +11,29 @@ module Bridgetown
11
11
  # Read Site data from disk and load it into internal data structures.
12
12
  #
13
13
  # Returns nothing.
14
- # rubocop:disable Metrics/AbcSize
15
- def read
16
- @site.defaults_reader.read
17
- @site.layouts = LayoutReader.new(site).read
14
+ def read # rubocop:todo Metrics/AbcSize
15
+ site.defaults_reader.read
16
+ site.layouts = LayoutReader.new(site).read
18
17
  read_directories
19
18
  read_included_excludes
20
19
  sort_files!
21
- @site.data = DataReader.new(site).read(site.config["data_dir"])
22
- CollectionReader.new(site).read
20
+ read_collections
21
+ site.data = if site.uses_resource?
22
+ site.collections.data.merge_data_resources
23
+ else
24
+ DataReader.new(site).read
25
+ end
23
26
  Bridgetown::PluginManager.source_manifests.map(&:content).compact.each do |plugin_content_dir|
24
27
  PluginContentReader.new(site, plugin_content_dir).read
25
28
  end
26
29
  end
27
- # rubocop:enable Metrics/AbcSize
30
+
31
+ def read_collections
32
+ site.collections.each_value do |collection|
33
+ collection.read unless !site.uses_resource? &&
34
+ collection.legacy_reader?
35
+ end
36
+ end
28
37
 
29
38
  # Sorts posts, pages, and static files.
30
39
  def sort_files!
@@ -54,14 +63,14 @@ module Bridgetown
54
63
  file_path = @site.in_source_dir(base, entry)
55
64
  if File.directory?(file_path)
56
65
  dot_dirs << entry
57
- elsif Utils.has_yaml_header?(file_path)
66
+ elsif Utils.has_yaml_header?(file_path) || Utils.has_rbfm_header?(file_path)
58
67
  dot_pages << entry
59
68
  else
60
69
  dot_static_files << entry
61
70
  end
62
71
  end
63
72
 
64
- retrieve_posts(dir)
73
+ retrieve_posts(dir) unless site.uses_resource?
65
74
  retrieve_dirs(base, dir, dot_dirs)
66
75
  retrieve_pages(dir, dot_pages)
67
76
  retrieve_static_files(dir, dot_static_files)
@@ -89,7 +98,7 @@ module Bridgetown
89
98
  def retrieve_dirs(_base, dir, dot_dirs)
90
99
  dot_dirs.each do |file|
91
100
  dir_path = site.in_source_dir(dir, file)
92
- rel_path = PathManager.join(dir, file)
101
+ rel_path = File.join(dir, file)
93
102
  @site.reader.read_directories(rel_path) unless @site.dest.chomp("/") == dir_path
94
103
  end
95
104
  end
@@ -102,18 +111,27 @@ module Bridgetown
102
111
  #
103
112
  # Returns nothing.
104
113
  def retrieve_pages(dir, dot_pages)
114
+ if site.uses_resource?
115
+ dot_pages.each do |page_path|
116
+ site.collections.pages.read_resource(site.in_source_dir(dir, page_path))
117
+ end
118
+ return
119
+ end
120
+
105
121
  site.pages.concat(PageReader.new(site, dir).read(dot_pages))
106
122
  end
107
123
 
108
124
  # Retrieve all the static files from the current directory,
109
125
  # add them to the site and sort them.
110
126
  #
111
- # dir - The directory retrieve the static files from.
112
- # dot_static_files - The static files in the dir.
113
- #
114
- # Returns nothing.
115
- def retrieve_static_files(dir, dot_static_files)
116
- site.static_files.concat(StaticFileReader.new(site, dir).read(dot_static_files))
127
+ # @param dir [String] The directory retrieve the static files from.
128
+ # @param files [Array<String>] The static files in the dir.
129
+ def retrieve_static_files(dir, files)
130
+ site.static_files.concat(
131
+ files.map do |file|
132
+ StaticFile.new(site, site.source, dir, file)
133
+ end
134
+ )
117
135
  end
118
136
 
119
137
  # Filter out any files/directories that are hidden or backup files (start
@@ -126,7 +144,7 @@ module Bridgetown
126
144
  #
127
145
  # Returns the Array of filtered entries.
128
146
  def filter_entries(entries, base_directory = nil)
129
- EntryFilter.new(site, base_directory).filter(entries)
147
+ EntryFilter.new(site, base_directory: base_directory).filter(entries)
130
148
  end
131
149
 
132
150
  # Read the entries from a particular directory for processing
@@ -165,14 +183,11 @@ module Bridgetown
165
183
  end
166
184
 
167
185
  def read_included_excludes
168
- entry_filter = EntryFilter.new(site)
169
-
170
- site.include.each do |entry|
186
+ site.config.include.each do |entry|
171
187
  next if entry == ".htaccess"
172
188
 
173
189
  entry_path = site.in_source_dir(entry)
174
190
  next if File.directory?(entry_path)
175
- next if entry_filter.symlink?(entry_path)
176
191
 
177
192
  read_included_file(entry_path) if File.file?(entry_path)
178
193
  end
@@ -184,7 +199,7 @@ module Bridgetown
184
199
  if Utils.has_yaml_header?(entry_path)
185
200
  site.pages.concat(PageReader.new(site, dir).read(file))
186
201
  else
187
- site.static_files.concat(StaticFileReader.new(site, dir).read(file))
202
+ retrieve_static_files(dir, file)
188
203
  end
189
204
  end
190
205
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bridgetown
4
+ # TODO: to be retired once the Resource engine is made official
4
5
  class DataReader
5
6
  attr_reader :site, :content
6
7
 
@@ -16,8 +17,8 @@ module Bridgetown
16
17
  #
17
18
  # Returns @content, a Hash of the .yaml, .yml,
18
19
  # .json, and .csv files in the base directory
19
- def read(dir)
20
- base = site.in_source_dir(dir)
20
+ def read
21
+ base = site.in_source_dir(site.config.data_dir)
21
22
  read_data_to(base, @content)
22
23
  merge_environment_specific_metadata!
23
24
  @content = @content.with_dot_access
@@ -31,7 +32,7 @@ module Bridgetown
31
32
  #
32
33
  # Returns nothing
33
34
  def read_data_to(dir, data)
34
- return unless File.directory?(dir) && !@entry_filter.symlink?(dir)
35
+ return unless File.directory?(dir)
35
36
 
36
37
  entries = Dir.chdir(dir) do
37
38
  Dir["*.{yaml,yml,json,csv,tsv}"] + Dir["*"].select { |fn| File.directory?(fn) }
@@ -39,7 +40,6 @@ module Bridgetown
39
40
 
40
41
  entries.each do |entry|
41
42
  path = @site.in_source_dir(dir, entry)
42
- next if @entry_filter.symlink?(path)
43
43
 
44
44
  if File.directory?(path)
45
45
  read_data_to(
@@ -68,7 +68,7 @@ module Bridgetown
68
68
  headers: true,
69
69
  encoding: site.config["encoding"]).map(&:to_hash)
70
70
  else
71
- SafeYAML.load_file(path)
71
+ YAMLParser.load_file(path)
72
72
  end
73
73
  end
74
74
 
@@ -18,7 +18,7 @@ module Bridgetown
18
18
 
19
19
  entries.each do |entry|
20
20
  path = @site.in_source_dir(entry)
21
- @path_defaults[File.dirname(path) + File::SEPARATOR] = SafeYAML.load_file(path)
21
+ @path_defaults[File.dirname(path) + File::SEPARATOR] = YAMLParser.load_file(path)
22
22
  end
23
23
 
24
24
  @path_defaults
@@ -44,7 +44,7 @@ module Bridgetown
44
44
  end
45
45
 
46
46
  def layout_name(file)
47
- file.split(".")[0..-2].join(".")
47
+ Layout.label_for_file(file)
48
48
  end
49
49
 
50
50
  def within(directory)
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bridgetown
4
+ # TODO: to be retired once the Resource engine is made official
4
5
  class PageReader
5
6
  attr_reader :site, :dir, :unfiltered_content
6
7
 
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bridgetown
4
+ # TODO: to be retired once the Resource engine is made official
4
5
  class PostReader
5
6
  attr_reader :site, :unfiltered_content
6
7
 
@@ -47,7 +48,7 @@ module Bridgetown
47
48
  # Process as Document
48
49
  Document.new(path,
49
50
  site: @site,
50
- collection: @site.posts)
51
+ collection: @site.collections.posts)
51
52
  else
52
53
  # Process as Static File
53
54
  read_static_file(
@@ -66,7 +67,7 @@ module Bridgetown
66
67
  site.source,
67
68
  relative_dir,
68
69
  File.basename(full_path),
69
- @site.posts
70
+ @site.collections.posts
70
71
  )
71
72
  end
72
73
 
@@ -96,9 +97,9 @@ module Bridgetown
96
97
  return false unless processable?(item)
97
98
 
98
99
  if item.is_a?(Document)
99
- site.posts.docs << item
100
+ site.collections.posts.docs << item
100
101
  elsif item.is_a?(StaticFile)
101
- site.posts.files << item
102
+ site.collections.posts.static_files << item
102
103
  site.static_files << item
103
104
  end
104
105
 
@@ -19,7 +19,7 @@ module Bridgetown
19
19
  # Checks if a renderable object needs to be regenerated
20
20
  #
21
21
  # Returns a boolean.
22
- def regenerate?(document)
22
+ def regenerate?(document) # rubocop:todo Metrics/CyclomaticComplexity
23
23
  return true if disabled
24
24
 
25
25
  case document
@@ -27,6 +27,8 @@ module Bridgetown
27
27
  regenerate_page?(document)
28
28
  when Document
29
29
  regenerate_document?(document)
30
+ when Bridgetown::Resource::Base
31
+ regenerate_resource?(document)
30
32
  else
31
33
  source_path = document.respond_to?(:path) ? document.path : nil
32
34
  dest_path = document.destination(@site.dest) if document.respond_to?(:destination)
@@ -152,7 +154,7 @@ module Bridgetown
152
154
  begin
153
155
  Marshal.load(content)
154
156
  rescue TypeError
155
- SafeYAML.load(content)
157
+ YAMLParser.load(content)
156
158
  rescue ArgumentError => e
157
159
  Bridgetown.logger.warn("Failed to load #{metadata_file}: #{e}")
158
160
  {}
@@ -176,6 +178,11 @@ module Bridgetown
176
178
  )
177
179
  end
178
180
 
181
+ # TODO: need to manage dependencies, but for now always regenerate
182
+ def regenerate_resource?(_resource)
183
+ true
184
+ end
185
+
179
186
  def existing_file_modified?(path)
180
187
  # If one of this file dependencies have been modified,
181
188
  # set the regeneration bit for both the dependency and the file to true
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bridgetown
4
+ # TODO: to be retired once the Resource engine is made official
4
5
  class RelatedPosts
5
6
  class << self
6
7
  attr_accessor :lsi
@@ -11,13 +12,15 @@ module Bridgetown
11
12
  def initialize(post)
12
13
  @post = post
13
14
  @site = post.site
14
- Bridgetown::External.require_with_graceful_fail("classifier-reborn") if site.lsi
15
+ if site.config.lsi
16
+ Bridgetown::Utils::RequireGems.require_with_graceful_fail("classifier-reborn")
17
+ end
15
18
  end
16
19
 
17
20
  def build
18
- return [] unless site.posts.docs.size > 1
21
+ return [] unless site.collections.posts.docs.size > 1
19
22
 
20
- if site.lsi
23
+ if site.config.lsi
21
24
  build_index
22
25
  lsi_related_posts
23
26
  else
@@ -30,7 +33,7 @@ module Bridgetown
30
33
  lsi = ClassifierReborn::LSI.new(auto_rebuild: false)
31
34
  Bridgetown.logger.info("Populating LSI...")
32
35
 
33
- site.posts.docs.each do |x|
36
+ site.collections.posts.docs.each do |x|
34
37
  lsi.add_item(x)
35
38
  end
36
39
 
@@ -42,11 +45,11 @@ module Bridgetown
42
45
  end
43
46
 
44
47
  def lsi_related_posts
45
- self.class.lsi.find_related(post, 11)
48
+ self.class.lsi.find_related(post, 11) - [post]
46
49
  end
47
50
 
48
51
  def most_recent_posts
49
- @most_recent_posts ||= (site.posts.docs.last(11).reverse - [post]).first(10)
52
+ @most_recent_posts ||= (site.collections.posts.docs.last(11).reverse - [post]).first(10)
50
53
  end
51
54
  end
52
55
  end
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bridgetown
4
+ # This class handles the output rendering and layout placement of pages and
5
+ # documents. For rendering of resources in particular, see Bridgetown::Resource::Transformer
4
6
  class Renderer
5
7
  attr_reader :document, :site
6
8
 
@@ -50,7 +52,7 @@ module Bridgetown
50
52
  output = document.content
51
53
  Bridgetown.logger.debug "Rendering Markup:", document.relative_path
52
54
  output = convert(output.to_s, document)
53
- document.content = output
55
+ document.content = output.html_safe
54
56
 
55
57
  if document.place_in_layout?
56
58
  Bridgetown.logger.debug "Rendering Layout:", document.relative_path
@@ -121,21 +123,11 @@ module Bridgetown
121
123
  "in #{document.relative_path} does not exist."
122
124
  end
123
125
 
124
- def converters_for_layout(layout)
125
- site.converters.select do |converter|
126
- if converter.method(:matches).arity == 1
127
- converter.matches(layout.ext)
128
- else
129
- converter.matches(layout.ext, layout)
130
- end
131
- end.sort
132
- end
133
-
134
126
  # Render layout content into document.output
135
127
  #
136
128
  # Returns String rendered content
137
129
  def render_layout(output, layout)
138
- layout_converters = converters_for_layout(layout)
130
+ layout_converters = site.matched_converters_for_convertible(layout)
139
131
 
140
132
  layout_content = layout.content.dup
141
133
  layout_converters.reduce(layout_content) do |layout_output, converter|
@@ -163,7 +155,8 @@ module Bridgetown
163
155
 
164
156
  def permalink_ext
165
157
  document_permalink = document.permalink
166
- if document_permalink && !document_permalink.end_with?("/")
158
+ if document_permalink &&
159
+ !document_permalink.end_with?("/")
167
160
  permalink_ext = File.extname(document_permalink)
168
161
  permalink_ext unless permalink_ext.empty?
169
162
  end