bridgetown-core 0.18.6 → 0.20.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/bridgetown +6 -0
- data/bridgetown-core.gemspec +4 -4
- data/lib/bridgetown-core.rb +46 -13
- data/lib/bridgetown-core/cleaner.rb +7 -1
- data/lib/bridgetown-core/collection.rb +173 -77
- data/lib/bridgetown-core/commands/apply.rb +4 -3
- data/lib/bridgetown-core/commands/base.rb +9 -0
- data/lib/bridgetown-core/commands/concerns/actions.rb +0 -5
- data/lib/bridgetown-core/commands/configure.rb +66 -0
- data/lib/bridgetown-core/commands/console.rb +4 -0
- data/lib/bridgetown-core/commands/new.rb +28 -1
- data/lib/bridgetown-core/commands/plugins.rb +1 -0
- data/lib/bridgetown-core/concerns/data_accessible.rb +1 -0
- data/lib/bridgetown-core/concerns/site/configurable.rb +7 -3
- data/lib/bridgetown-core/concerns/site/content.rb +57 -15
- data/lib/bridgetown-core/concerns/site/processable.rb +1 -0
- data/lib/bridgetown-core/concerns/site/renderable.rb +26 -0
- data/lib/bridgetown-core/concerns/site/writable.rb +11 -1
- data/lib/bridgetown-core/concerns/validatable.rb +1 -0
- data/lib/bridgetown-core/configuration.rb +39 -19
- data/lib/bridgetown-core/configurations/.keep +0 -0
- data/lib/bridgetown-core/configurations/bt-postcss.rb +26 -0
- data/lib/bridgetown-core/configurations/bt-postcss/postcss.config.js +21 -0
- data/lib/bridgetown-core/configurations/minitesting.rb +95 -0
- data/lib/bridgetown-core/configurations/netlify.rb +6 -0
- data/lib/bridgetown-core/configurations/netlify/netlify.sh +14 -0
- data/lib/bridgetown-core/configurations/netlify/netlify.toml +44 -0
- data/lib/bridgetown-core/configurations/purgecss.rb +49 -0
- data/lib/bridgetown-core/configurations/stimulus.rb +49 -0
- data/lib/bridgetown-core/configurations/swup.rb +37 -0
- data/lib/bridgetown-core/configurations/tailwindcss.rb +29 -0
- data/lib/bridgetown-core/configurations/tailwindcss/css_imports.css +4 -0
- data/lib/bridgetown-core/configurations/tailwindcss/postcss.config.js +12 -0
- data/lib/bridgetown-core/configurations/turbo.rb +16 -0
- data/lib/bridgetown-core/converter.rb +14 -0
- data/lib/bridgetown-core/converters/erb_templates.rb +6 -13
- data/lib/bridgetown-core/converters/identity.rb +0 -9
- data/lib/bridgetown-core/converters/markdown.rb +14 -4
- data/lib/bridgetown-core/converters/markdown/kramdown_parser.rb +3 -0
- data/lib/bridgetown-core/current.rb +10 -0
- data/lib/bridgetown-core/document.rb +6 -14
- data/lib/bridgetown-core/drops/collection_drop.rb +1 -1
- data/lib/bridgetown-core/drops/page_drop.rb +4 -0
- data/lib/bridgetown-core/drops/resource_drop.rb +81 -0
- data/lib/bridgetown-core/drops/site_drop.rb +33 -8
- data/lib/bridgetown-core/drops/unified_payload_drop.rb +4 -0
- data/lib/bridgetown-core/entry_filter.rb +10 -23
- data/lib/bridgetown-core/errors.rb +0 -2
- data/lib/bridgetown-core/filters.rb +4 -3
- data/lib/bridgetown-core/generator.rb +2 -1
- data/lib/bridgetown-core/generators/prototype_generator.rb +37 -19
- data/lib/bridgetown-core/layout.rb +2 -2
- data/lib/bridgetown-core/liquid_renderer/file.rb +1 -0
- data/lib/bridgetown-core/liquid_renderer/table.rb +1 -0
- data/lib/bridgetown-core/model/base.rb +138 -0
- data/lib/bridgetown-core/model/builder_origin.rb +40 -0
- data/lib/bridgetown-core/model/file_origin.rb +119 -0
- data/lib/bridgetown-core/model/origin.rb +38 -0
- data/lib/bridgetown-core/page.rb +9 -1
- data/lib/bridgetown-core/plugin.rb +2 -26
- data/lib/bridgetown-core/plugin_manager.rb +0 -2
- data/lib/bridgetown-core/publisher.rb +7 -1
- data/lib/bridgetown-core/reader.rb +25 -12
- data/lib/bridgetown-core/readers/data_reader.rb +3 -4
- data/lib/bridgetown-core/readers/post_reader.rb +1 -1
- data/lib/bridgetown-core/regenerator.rb +8 -1
- data/lib/bridgetown-core/related_posts.rb +1 -1
- data/lib/bridgetown-core/renderer.rb +5 -12
- data/lib/bridgetown-core/resource/base.rb +275 -0
- data/lib/bridgetown-core/resource/destination.rb +49 -0
- data/lib/bridgetown-core/resource/permalink_processor.rb +179 -0
- data/lib/bridgetown-core/resource/taxonomy_term.rb +25 -0
- data/lib/bridgetown-core/resource/taxonomy_type.rb +47 -0
- data/lib/bridgetown-core/resource/transformer.rb +173 -0
- data/lib/bridgetown-core/ruby_template_view.rb +13 -2
- data/lib/bridgetown-core/site.rb +9 -1
- data/lib/bridgetown-core/static_file.rb +33 -10
- data/lib/bridgetown-core/url.rb +1 -0
- data/lib/bridgetown-core/utils.rb +40 -40
- data/lib/bridgetown-core/utils/platforms.rb +1 -0
- data/lib/bridgetown-core/version.rb +2 -2
- data/lib/site_template/README.md +70 -0
- data/lib/site_template/frontend/javascript/index.js.erb +11 -0
- data/lib/site_template/frontend/styles/index.css +19 -0
- data/lib/site_template/{package.json → package.json.erb} +14 -8
- data/lib/site_template/postcss.config.js.erb +11 -0
- data/lib/site_template/src/_components/footer.liquid +1 -1
- data/lib/site_template/src/_posts/0000-00-00-welcome-to-bridgetown.md.erb +1 -1
- data/lib/site_template/{webpack.config.js → webpack.config.js.erb} +47 -5
- metadata +67 -42
- data/lib/bridgetown-core/page_without_a_file.rb +0 -14
- data/lib/bridgetown-core/readers/collection_reader.rb +0 -23
- data/lib/bridgetown-core/utils/exec.rb +0 -26
- data/lib/bridgetown-core/utils/internet.rb +0 -37
- data/lib/bridgetown-core/utils/win_tz.rb +0 -75
- data/lib/site_template/frontend/javascript/index.js +0 -3
@@ -26,6 +26,7 @@ module Bridgetown
|
|
26
26
|
|
27
27
|
def apply_automation
|
28
28
|
@source_paths = [Dir.pwd]
|
29
|
+
@logger = Bridgetown.logger
|
29
30
|
|
30
31
|
if options[:apply]
|
31
32
|
apply_after_new_command
|
@@ -33,9 +34,9 @@ module Bridgetown
|
|
33
34
|
apply_in_pwd
|
34
35
|
end
|
35
36
|
rescue SystemExit => e
|
36
|
-
|
37
|
+
@logger.error "Problem occurred while running automation:"
|
37
38
|
e.backtrace[0..3].each do |backtrace_line|
|
38
|
-
|
39
|
+
@logger.info backtrace_line if backtrace_line.include?(":in `apply'")
|
39
40
|
end
|
40
41
|
raise e
|
41
42
|
end
|
@@ -66,7 +67,7 @@ module Bridgetown
|
|
66
67
|
apply_from_url automation_command
|
67
68
|
end
|
68
69
|
rescue ArgumentError => e
|
69
|
-
|
70
|
+
@logger.warn "Oops!", e.message
|
70
71
|
end
|
71
72
|
end
|
72
73
|
end
|
@@ -25,6 +25,15 @@ module Bridgetown
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
desc "dream", "There's a place where that idea still exists as a reality"
|
29
|
+
def dream
|
30
|
+
puts ""
|
31
|
+
puts "🎶 The Dream of the 90s is Alive in Portland... ✨"
|
32
|
+
puts " https://youtu.be/U4hShMEk1Ew"
|
33
|
+
puts " https://youtu.be/0_HGqPGp9iY"
|
34
|
+
puts ""
|
35
|
+
end
|
36
|
+
|
28
37
|
desc "help <command>", "Show detailed command usage information and exit"
|
29
38
|
def help(subcommand = nil)
|
30
39
|
if subcommand && respond_to?(subcommand)
|
@@ -1,10 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Mostly not used here, but may come in handy in new automations
|
4
|
-
require "active_support/core_ext/array/extract_options"
|
5
|
-
require "active_support/core_ext/string/strip"
|
6
|
-
require "active_support/core_ext/string/indent"
|
7
|
-
|
8
3
|
module Bridgetown
|
9
4
|
module Commands
|
10
5
|
module Actions
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bridgetown
|
4
|
+
module Commands
|
5
|
+
class Configure < Thor::Group
|
6
|
+
include Thor::Actions
|
7
|
+
extend Summarizable
|
8
|
+
|
9
|
+
Registrations.register do
|
10
|
+
register(Configure, "configure", "configure CONFIGURATION", Configure.summary)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.banner
|
14
|
+
"bridgetown configure CONFIGURATION(S)"
|
15
|
+
end
|
16
|
+
summary "Set up bundled Bridgetown configurations"
|
17
|
+
|
18
|
+
def self.exit_on_failure?
|
19
|
+
true
|
20
|
+
end
|
21
|
+
|
22
|
+
def perform_configurations
|
23
|
+
logger = Bridgetown.logger
|
24
|
+
list_configurations if args.empty?
|
25
|
+
|
26
|
+
args.each do |configuration|
|
27
|
+
configure configuration
|
28
|
+
rescue Thor::Error
|
29
|
+
logger.error "Error:".red, "🚨 Configuration doesn't exist: #{configuration}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.source_root
|
34
|
+
File.expand_path("../configurations", __dir__)
|
35
|
+
end
|
36
|
+
|
37
|
+
protected
|
38
|
+
|
39
|
+
def configure(configuration)
|
40
|
+
configuration_file = find_in_source_paths("#{configuration}.rb")
|
41
|
+
|
42
|
+
inside(New.created_site_dir || Dir.pwd) do
|
43
|
+
Apply.new.invoke(:apply_automation, [configuration_file])
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def list_configurations
|
48
|
+
say "Please specify a valid packaged configuration from the below list:\n\n"
|
49
|
+
configurations.each do |configuration|
|
50
|
+
configuration = set_color configuration, :blue, :bold
|
51
|
+
say configuration
|
52
|
+
end
|
53
|
+
say "\n"
|
54
|
+
|
55
|
+
docs_url = "https://www.bridgetownrb.com/docs/bundled-configurations".yellow.bold
|
56
|
+
say "For more info, check out the docs at: #{docs_url}"
|
57
|
+
end
|
58
|
+
|
59
|
+
def configurations
|
60
|
+
inside self.class.source_root do
|
61
|
+
return Dir.glob("*.rb").map { |file| file.sub(".rb", "") }
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -28,6 +28,7 @@ module Bridgetown
|
|
28
28
|
|
29
29
|
def console
|
30
30
|
require "irb"
|
31
|
+
require "irb/ext/save-history"
|
31
32
|
require "amazing_print" unless options[:"bypass-ap"]
|
32
33
|
|
33
34
|
Bridgetown.logger.info "Starting:", "Bridgetown v#{Bridgetown::VERSION.magenta}" \
|
@@ -50,6 +51,7 @@ module Bridgetown
|
|
50
51
|
IRB.setup(nil)
|
51
52
|
workspace = IRB::WorkSpace.new
|
52
53
|
irb = IRB::Irb.new(workspace)
|
54
|
+
IRB.conf[:IRB_RC]&.call(irb.context)
|
53
55
|
IRB.conf[:MAIN_CONTEXT] = irb.context
|
54
56
|
eval("site = $BRIDGETOWN_SITE", workspace.binding, __FILE__, __LINE__)
|
55
57
|
Bridgetown.logger.info "Console:", "Now loaded as " + "site".cyan + " variable."
|
@@ -68,6 +70,8 @@ module Bridgetown
|
|
68
70
|
end
|
69
71
|
irb.eval_input
|
70
72
|
end
|
73
|
+
ensure
|
74
|
+
IRB.conf[:AT_EXIT].each(&:call)
|
71
75
|
end
|
72
76
|
end
|
73
77
|
end
|
@@ -19,6 +19,10 @@ module Bridgetown
|
|
19
19
|
aliases: "-a",
|
20
20
|
banner: "PATH|URL",
|
21
21
|
desc: "Apply an automation after creating the site scaffold"
|
22
|
+
class_option :configure,
|
23
|
+
aliases: "-c",
|
24
|
+
banner: "CONFIGURATION(S)",
|
25
|
+
desc: "Comma separated list of bundled configurations to perform"
|
22
26
|
class_option :force,
|
23
27
|
type: :boolean,
|
24
28
|
desc: "Force creation even if PATH already exists"
|
@@ -28,6 +32,9 @@ module Bridgetown
|
|
28
32
|
class_option :"skip-yarn",
|
29
33
|
type: :boolean,
|
30
34
|
desc: "Skip 'yarn install'"
|
35
|
+
class_option :"use-postcss",
|
36
|
+
type: :boolean,
|
37
|
+
desc: "Create an empty PostCSS configuration instead of using Sass"
|
31
38
|
|
32
39
|
DOCSURL = "https://bridgetownrb.com/docs"
|
33
40
|
|
@@ -47,6 +54,8 @@ module Bridgetown
|
|
47
54
|
raise ArgumentError, "You must specify a path." if args.empty?
|
48
55
|
|
49
56
|
new_site_path = File.expand_path(args.join(" "), Dir.pwd)
|
57
|
+
@site_name = new_site_path.split(File::SEPARATOR).last
|
58
|
+
|
50
59
|
if preserve_source_location?(new_site_path, options)
|
51
60
|
say_status :conflict, "#{new_site_path} exists and is not empty.", :red
|
52
61
|
Bridgetown.logger.abort_with "Ensure #{new_site_path} is empty or else " \
|
@@ -67,7 +76,7 @@ module Bridgetown
|
|
67
76
|
end
|
68
77
|
|
69
78
|
def create_site(new_site_path)
|
70
|
-
directory ".", ".", exclude_pattern: %r!\.erb|DS_Store$!
|
79
|
+
directory ".", ".", exclude_pattern: %r!\.erb|DS_Store$|\.(s[ac]|c)ss$!
|
71
80
|
FileUtils.chmod_R "u+w", new_site_path
|
72
81
|
|
73
82
|
template(
|
@@ -75,12 +84,27 @@ module Bridgetown
|
|
75
84
|
"src/_posts/#{Time.now.strftime("%Y-%m-%d")}-welcome-to-bridgetown.md"
|
76
85
|
)
|
77
86
|
template("Gemfile.erb", "Gemfile")
|
87
|
+
template("package.json.erb", "package.json")
|
88
|
+
template("webpack.config.js.erb", "webpack.config.js")
|
89
|
+
template("frontend/javascript/index.js.erb", "frontend/javascript/index.js")
|
90
|
+
|
91
|
+
options["use-postcss"] ? configure_postcss : configure_sass
|
92
|
+
end
|
93
|
+
|
94
|
+
def configure_sass
|
95
|
+
copy_file("frontend/styles/index.scss")
|
96
|
+
end
|
97
|
+
|
98
|
+
def configure_postcss
|
99
|
+
template("postcss.config.js.erb", "postcss.config.js")
|
100
|
+
copy_file("frontend/styles/index.css")
|
78
101
|
end
|
79
102
|
|
80
103
|
# After a new site has been created, print a success notification and
|
81
104
|
# then automatically execute bundle install from within the new site dir
|
82
105
|
# unless the user opts to skip 'bundle install'.
|
83
106
|
# rubocop:todo Metrics/CyclomaticComplexity
|
107
|
+
# rubocop:disable Metrics/PerceivedComplexity
|
84
108
|
def after_install(path, cli_path, options = {})
|
85
109
|
git_init path
|
86
110
|
|
@@ -91,6 +115,7 @@ module Bridgetown
|
|
91
115
|
yarn_install path unless options["skip-yarn"]
|
92
116
|
|
93
117
|
invoke(Apply, [], options) if options[:apply]
|
118
|
+
invoke(Configure, options[:configure].split(","), {}) if options[:configure]
|
94
119
|
|
95
120
|
logger = Bridgetown.logger
|
96
121
|
yarn_start = "yarn start"
|
@@ -111,6 +136,7 @@ module Bridgetown
|
|
111
136
|
logger.info "Yarn install skipped.".yellow if @skipped_yarn
|
112
137
|
end
|
113
138
|
# rubocop:enable Metrics/CyclomaticComplexity
|
139
|
+
# rubocop:enable Metrics/PerceivedComplexity
|
114
140
|
|
115
141
|
def bundle_install(path)
|
116
142
|
unless Bridgetown.environment == "test"
|
@@ -132,6 +158,7 @@ module Bridgetown
|
|
132
158
|
unless Bridgetown.environment == "test"
|
133
159
|
inside(path) do
|
134
160
|
run "git init", abort_on_failure: true
|
161
|
+
run "if [[ -n $(git status | grep 'On branch master') ]]; then git checkout -b main; fi"
|
135
162
|
end
|
136
163
|
end
|
137
164
|
rescue SystemExit
|
@@ -150,6 +150,7 @@ module Bridgetown
|
|
150
150
|
inside name do # rubocop:todo Metrics/BlockLength
|
151
151
|
run "rm -rf .git"
|
152
152
|
run "git init"
|
153
|
+
run "if [[ -n $(git status | grep 'On branch master') ]]; then git checkout -b main; fi"
|
153
154
|
|
154
155
|
run "mv bridgetown-sample-plugin.gemspec #{new_gemspec}"
|
155
156
|
gsub_file new_gemspec, "https://github.com/bridgetownrb/bridgetown-sample-plugin", "https://github.com/username/#{name}"
|
@@ -30,11 +30,15 @@ class Bridgetown::Site
|
|
30
30
|
configure_include_paths
|
31
31
|
configure_file_read_opts
|
32
32
|
|
33
|
-
self.permalink_style = config["permalink"].to_sym
|
33
|
+
self.permalink_style = (config["permalink"] || "pretty").to_sym
|
34
34
|
|
35
35
|
@config
|
36
36
|
end
|
37
37
|
|
38
|
+
def uses_resource?
|
39
|
+
config[:content_engine] == "resource"
|
40
|
+
end
|
41
|
+
|
38
42
|
def defaults_reader
|
39
43
|
@defaults_reader ||= Bridgetown::DefaultsReader.new(self)
|
40
44
|
end
|
@@ -78,7 +82,7 @@ class Bridgetown::Site
|
|
78
82
|
# @return [Array<String>] Return an array of updated paths if multiple paths given.
|
79
83
|
def in_root_dir(*paths)
|
80
84
|
paths.reduce(root_dir) do |base, path|
|
81
|
-
Bridgetown.sanitized_path(base, path)
|
85
|
+
Bridgetown.sanitized_path(base, path.to_s)
|
82
86
|
end
|
83
87
|
end
|
84
88
|
|
@@ -91,7 +95,7 @@ class Bridgetown::Site
|
|
91
95
|
# @return [Array<String>] Return an array of updated paths if multiple paths given.
|
92
96
|
def in_source_dir(*paths)
|
93
97
|
paths.reduce(source) do |base, path|
|
94
|
-
Bridgetown.sanitized_path(base, path)
|
98
|
+
Bridgetown.sanitized_path(base, path.to_s)
|
95
99
|
end
|
96
100
|
end
|
97
101
|
|
@@ -32,6 +32,18 @@ class Bridgetown::Site
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
def resources_grouped_by_taxonomy(taxonomy)
|
36
|
+
@post_attr_hash[taxonomy.label] ||= begin
|
37
|
+
taxonomy.terms.transform_values { |terms| terms.map(&:resource).sort.reverse }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def taxonomies
|
42
|
+
taxonomy_types.transform_values do |taxonomy|
|
43
|
+
resources_grouped_by_taxonomy(taxonomy)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
35
47
|
# Returns a hash of "tags" using {#post_attr_hash} where each tag is a key
|
36
48
|
# and each value is a post which contains the key.
|
37
49
|
# @example
|
@@ -41,7 +53,7 @@ class Bridgetown::Site
|
|
41
53
|
# @return [Hash{String, Array<Post>}] Returns a hash of all tags and their corresponding posts
|
42
54
|
# @see post_attr_hash
|
43
55
|
def tags
|
44
|
-
post_attr_hash("tags")
|
56
|
+
uses_resource? ? taxonomies.tag : post_attr_hash("tags")
|
45
57
|
end
|
46
58
|
|
47
59
|
# Returns a hash of "categories" using {#post_attr_hash} where each tag is
|
@@ -54,7 +66,7 @@ class Bridgetown::Site
|
|
54
66
|
# their corresponding posts
|
55
67
|
# @see post_attr_hash
|
56
68
|
def categories
|
57
|
-
post_attr_hash("categories")
|
69
|
+
uses_resource? ? taxonomies.category : post_attr_hash("categories")
|
58
70
|
end
|
59
71
|
|
60
72
|
# Returns the value of `data["site_metadata"]` or creates a new instance of
|
@@ -121,19 +133,25 @@ class Bridgetown::Site
|
|
121
133
|
# An array of collection names.
|
122
134
|
# @return [Array<String>] an array of collection names from the configuration,
|
123
135
|
# or an empty array if the `config["collections"]` key is not set.
|
124
|
-
# @raise ArgumentError Raise an error if `config["collections"]` is not
|
125
|
-
# an Array or a Hash
|
126
136
|
def collection_names
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
+
Array(config.collections&.keys)
|
138
|
+
end
|
139
|
+
|
140
|
+
# @return [Array<Bridgetown::Resource::TaxonomyType>]
|
141
|
+
def taxonomy_types
|
142
|
+
@taxonomy_types ||= config.taxonomies.map do |label, key_or_metadata|
|
143
|
+
key = key_or_metadata
|
144
|
+
tax_metadata = if key_or_metadata.is_a? Hash
|
145
|
+
key = key_or_metadata["key"]
|
146
|
+
key_or_metadata.reject { |k| k == "key" }
|
147
|
+
else
|
148
|
+
HashWithDotAccess::Hash.new
|
149
|
+
end
|
150
|
+
|
151
|
+
[label, Bridgetown::Resource::TaxonomyType.new(
|
152
|
+
site: self, label: label, key: key, metadata: tax_metadata
|
153
|
+
),]
|
154
|
+
end.to_h.with_dot_access
|
137
155
|
end
|
138
156
|
|
139
157
|
# Get all documents.
|
@@ -155,11 +173,29 @@ class Bridgetown::Site
|
|
155
173
|
documents.select(&:write?)
|
156
174
|
end
|
157
175
|
|
158
|
-
# Get all
|
176
|
+
# Get all documents.
|
177
|
+
# @return [Array<Document>] an array of documents from the
|
178
|
+
# configuration
|
179
|
+
def resources
|
180
|
+
collections.each_with_object(Set.new) do |(_, collection), set|
|
181
|
+
set.merge(collection.resources)
|
182
|
+
end.to_a
|
183
|
+
end
|
184
|
+
|
185
|
+
def resources_to_write
|
186
|
+
resources.select(&:write?)
|
187
|
+
end
|
188
|
+
|
189
|
+
# Get all posts. Deprecated, to be removed in v1.0.
|
159
190
|
#
|
160
191
|
# @return [Collection] Returns {#collections}`["posts"]`, creating it if need be
|
161
192
|
# @see Collection
|
162
193
|
def posts
|
194
|
+
unless @wrote_deprecation_msg
|
195
|
+
Bridgetown::Deprecator.deprecation_message "Call site.collections.posts " \
|
196
|
+
"instead of site.posts (Ruby code)"
|
197
|
+
end
|
198
|
+
@wrote_deprecation_msg ||= true
|
163
199
|
collections["posts"] ||= Bridgetown::Collection.new(self, "posts")
|
164
200
|
end
|
165
201
|
|
@@ -177,7 +213,13 @@ class Bridgetown::Site
|
|
177
213
|
#
|
178
214
|
# @return [Array]
|
179
215
|
def contents
|
216
|
+
return resources if uses_resource?
|
217
|
+
|
180
218
|
pages + documents
|
181
219
|
end
|
220
|
+
|
221
|
+
def add_generated_page(generated_page)
|
222
|
+
generated_pages << generated_page
|
223
|
+
end
|
182
224
|
end
|
183
225
|
end
|
@@ -29,6 +29,26 @@ class Bridgetown::Site
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
+
def matched_converters_for_convertible(convertible)
|
33
|
+
@layout_converters ||= {}
|
34
|
+
|
35
|
+
if convertible.is_a?(Bridgetown::Layout) && @layout_converters[convertible]
|
36
|
+
return @layout_converters[convertible]
|
37
|
+
end
|
38
|
+
|
39
|
+
matches = converters.select do |converter|
|
40
|
+
if converter.method(:matches).arity == 1
|
41
|
+
converter.matches(convertible.extname)
|
42
|
+
else
|
43
|
+
converter.matches(convertible.extname, convertible)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
@layout_converters[convertible] = matches if convertible.is_a?(Bridgetown::Layout)
|
48
|
+
|
49
|
+
matches
|
50
|
+
end
|
51
|
+
|
32
52
|
# Renders all documents
|
33
53
|
# @return [void]
|
34
54
|
def render_docs
|
@@ -38,6 +58,12 @@ class Bridgetown::Site
|
|
38
58
|
render_regenerated document
|
39
59
|
end
|
40
60
|
end
|
61
|
+
|
62
|
+
collection.resources.each do |resource|
|
63
|
+
render_with_locale(resource) do
|
64
|
+
resource.transform!
|
65
|
+
end
|
66
|
+
end
|
41
67
|
end
|
42
68
|
end
|
43
69
|
|