bridgetown-core 1.0.0.alpha11 → 1.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -0
  3. data/bin/bridgetown +6 -1
  4. data/bridgetown-core.gemspec +3 -3
  5. data/lib/bridgetown-core/commands/base.rb +18 -18
  6. data/lib/bridgetown-core/commands/build.rb +1 -1
  7. data/lib/bridgetown-core/commands/clean.rb +2 -2
  8. data/lib/bridgetown-core/commands/esbuild/esbuild.config.js +27 -0
  9. data/lib/bridgetown-core/commands/esbuild/esbuild.defaults.js.erb +216 -0
  10. data/lib/bridgetown-core/commands/esbuild/migrate-from-webpack.rb +47 -0
  11. data/lib/bridgetown-core/commands/esbuild/setup.rb +4 -0
  12. data/lib/bridgetown-core/commands/esbuild/update.rb +4 -0
  13. data/lib/bridgetown-core/commands/esbuild.rb +83 -0
  14. data/lib/bridgetown-core/commands/new.rb +80 -10
  15. data/lib/bridgetown-core/commands/webpack/enable-postcss.rb +1 -1
  16. data/lib/bridgetown-core/commands/webpack/update.rb +3 -3
  17. data/lib/bridgetown-core/commands/webpack/webpack.defaults.js.erb +1 -1
  18. data/lib/bridgetown-core/commands/webpack.rb +3 -3
  19. data/lib/bridgetown-core/component.rb +9 -3
  20. data/lib/bridgetown-core/concerns/site/configurable.rb +4 -0
  21. data/lib/bridgetown-core/concerns/site/content.rb +4 -4
  22. data/lib/bridgetown-core/configurations/purgecss.rb +2 -1
  23. data/lib/bridgetown-core/configurations/stimulus.rb +40 -12
  24. data/lib/bridgetown-core/configurations/tailwindcss/css_imports.css +5 -0
  25. data/lib/bridgetown-core/configurations/tailwindcss.rb +31 -2
  26. data/lib/bridgetown-core/configurations/turbo/turbo_transitions.js +48 -0
  27. data/lib/bridgetown-core/configurations/turbo.rb +15 -5
  28. data/lib/bridgetown-core/converters/erb_templates.rb +1 -1
  29. data/lib/bridgetown-core/converters/ruby_templates.rb +1 -1
  30. data/lib/bridgetown-core/converters/serbea_templates.rb +1 -1
  31. data/lib/bridgetown-core/errors.rb +21 -0
  32. data/lib/bridgetown-core/helpers.rb +3 -2
  33. data/lib/bridgetown-core/model/origin.rb +4 -6
  34. data/lib/bridgetown-core/rack/boot.rb +5 -9
  35. data/lib/bridgetown-core/ruby_template_view.rb +4 -0
  36. data/lib/bridgetown-core/tags/{webpack_path.rb → asset_path.rb} +7 -9
  37. data/lib/bridgetown-core/tasks/bridgetown_tasks.rake +2 -1
  38. data/lib/bridgetown-core/utils.rb +63 -9
  39. data/lib/bridgetown-core/version.rb +1 -1
  40. data/lib/bridgetown-core/watcher.rb +34 -34
  41. data/lib/bridgetown-core.rb +1 -0
  42. data/lib/site_template/Gemfile.erb +17 -11
  43. data/lib/site_template/README.md +2 -2
  44. data/lib/site_template/{Rakefile → Rakefile.erb} +15 -0
  45. data/lib/site_template/TEMPLATES/erb/_components/shared/navbar.erb +11 -0
  46. data/lib/site_template/TEMPLATES/erb/_components/shared/navbar.rb +5 -0
  47. data/lib/site_template/TEMPLATES/erb/_layouts/default.erb +15 -0
  48. data/lib/site_template/TEMPLATES/erb/_layouts/page.erb +7 -0
  49. data/lib/site_template/TEMPLATES/erb/_layouts/post.erb +7 -0
  50. data/lib/site_template/TEMPLATES/erb/_partials/_footer.erb +3 -0
  51. data/lib/site_template/TEMPLATES/erb/_partials/_head.erb +10 -0
  52. data/lib/site_template/{src → TEMPLATES/liquid}/_components/footer.liquid +0 -0
  53. data/lib/site_template/TEMPLATES/liquid/_components/head.liquid +10 -0
  54. data/lib/site_template/TEMPLATES/liquid/_components/navbar.liquid +11 -0
  55. data/lib/site_template/{src → TEMPLATES/liquid}/_layouts/default.liquid +2 -2
  56. data/lib/site_template/{src → TEMPLATES/liquid}/_layouts/page.liquid +0 -0
  57. data/lib/site_template/{src → TEMPLATES/liquid}/_layouts/post.liquid +0 -0
  58. data/lib/site_template/TEMPLATES/serbea/_components/shared/navbar.rb +5 -0
  59. data/lib/site_template/TEMPLATES/serbea/_components/shared/navbar.serb +11 -0
  60. data/lib/site_template/TEMPLATES/serbea/_layouts/default.serb +15 -0
  61. data/lib/site_template/TEMPLATES/serbea/_layouts/page.serb +7 -0
  62. data/lib/site_template/TEMPLATES/serbea/_layouts/post.serb +7 -0
  63. data/lib/site_template/TEMPLATES/serbea/_partials/_footer.serb +3 -0
  64. data/lib/site_template/TEMPLATES/serbea/_partials/_head.serb +10 -0
  65. data/lib/site_template/frontend/javascript/index.js.erb +7 -3
  66. data/lib/site_template/frontend/styles/index.css +71 -6
  67. data/lib/site_template/package.json.erb +24 -9
  68. data/lib/site_template/ruby-version.erb +1 -0
  69. data/lib/site_template/server/roda_app.rb +5 -3
  70. data/lib/site_template/server/routes/hello.rb.sample +1 -1
  71. data/lib/site_template/src/images/logo.svg +91 -0
  72. data/lib/site_template/src/index.md.erb +22 -0
  73. data/lib/site_template/src/posts.md.erb +28 -0
  74. metadata +53 -22
  75. data/lib/bridgetown-core/configurations/swup.rb +0 -37
  76. data/lib/site_template/frontend/styles/index.scss +0 -17
  77. data/lib/site_template/src/_components/head.liquid +0 -10
  78. data/lib/site_template/src/_components/navbar.liquid +0 -5
  79. data/lib/site_template/src/_layouts/home.liquid +0 -7
  80. data/lib/site_template/src/images/.keep +0 -1
  81. data/lib/site_template/src/index.md +0 -7
  82. data/lib/site_template/src/posts.md +0 -14
@@ -73,6 +73,10 @@ module Bridgetown
73
73
  helpers.respond_to?(method_name.to_sym, include_private) || super
74
74
  end
75
75
 
76
+ def inspect
77
+ "#<#{self.class} layout=#{layout&.label} resource=#{resource.relative_path}>"
78
+ end
79
+
76
80
  private
77
81
 
78
82
  def _render_statement(component, options)
@@ -2,9 +2,9 @@
2
2
 
3
3
  module Bridgetown
4
4
  module Tags
5
- # A helper class to help find the path to webpack asset inside of a webpack
5
+ # A helper class to help find the path to assets inside of a webpack or esbuild
6
6
  # manifest file.
7
- class WebpackPath < Liquid::Tag
7
+ class AssetPath < Liquid::Tag
8
8
  # @param tag_name [String] Name of the tag
9
9
  # @param asset_type [String] The type of asset to parse (js, css)
10
10
  # @param options [Hash] An options hash
@@ -17,23 +17,21 @@ module Bridgetown
17
17
  @asset_type = asset_type.strip
18
18
  end
19
19
 
20
- # Render an asset path based on the Webpack manifest file
20
+ # Render an asset path based on the frontend manifest file
21
21
  # @param context [Liquid::Context] Context passed to the tag
22
22
  #
23
23
  # @return [String] Returns "MISSING_WEBPACK_MANIFEST" if the manifest
24
- # file isn't found
24
+ # file isn't found
25
25
  # @return [String] Returns a blank string if the asset isn't found
26
26
  # @return [String] Returns the path to the asset if no issues parsing
27
- #
28
- # @raise [WebpackAssetError] if unable to find css or js in the manifest
29
- # file
30
27
  def render(context)
31
28
  @context = context
32
29
  site = context.registers[:site]
33
- Bridgetown::Utils.parse_webpack_manifest_file(site, @asset_type) || ""
30
+ Bridgetown::Utils.parse_frontend_manifest_file(site, @asset_type) || ""
34
31
  end
35
32
  end
36
33
  end
37
34
  end
38
35
 
39
- Liquid::Template.register_tag("webpack_path", Bridgetown::Tags::WebpackPath)
36
+ Liquid::Template.register_tag("asset_path", Bridgetown::Tags::AssetPath)
37
+ Liquid::Template.register_tag("webpack_path", Bridgetown::Tags::AssetPath)
@@ -15,7 +15,8 @@ namespace :frontend do
15
15
  run_process "Frontend", :yellow, "bundle exec bridgetown frontend:dev"
16
16
  end
17
17
  if sidecar
18
- sleep 4 # give Webpack time to boot before returning control to the start command
18
+ # give FE bundler time to boot before returning control to the start command
19
+ sleep Bridgetown::Utils.frontend_bundler_type == :esbuild ? 3 : 4
19
20
  else
20
21
  trap("INT") do
21
22
  Bridgetown::Utils::Aux.kill_processes
@@ -339,19 +339,34 @@ module Bridgetown
339
339
  end
340
340
  # rubocop:enable Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity
341
341
 
342
+ def parse_frontend_manifest_file(site, asset_type)
343
+ case frontend_bundler_type(site.root_dir)
344
+ when :webpack
345
+ parse_webpack_manifest_file(site, asset_type)
346
+ when :esbuild
347
+ parse_esbuild_manifest_file(site, asset_type)
348
+ else
349
+ Bridgetown.logger.warn(
350
+ "Frontend:",
351
+ "No frontend bundling configuration was found."
352
+ )
353
+ "MISSING_FRONTEND_BUNDLING_CONFIG"
354
+ end
355
+ end
356
+
342
357
  # Return an asset path based on the Webpack manifest file
343
358
  # @param site [Bridgetown::Site] The current site object
344
359
  # @param asset_type [String] js or css, or filename in manifest
345
360
  #
346
361
  # @return [String] Returns "MISSING_WEBPACK_MANIFEST" if the manifest
347
- # file isnt found
362
+ # file isnt found
348
363
  # @return [nil] Returns nil if the asset isnt found
349
364
  # @return [String] Returns the path to the asset if no issues parsing
350
365
  #
351
366
  # @raise [WebpackAssetError] if unable to find css or js in the manifest
352
- # file
367
+ # file
353
368
  def parse_webpack_manifest_file(site, asset_type)
354
- return log_webpack_asset_error(site, "Webpack manifest") if site.frontend_manifest.nil?
369
+ return log_frontend_asset_error(site, "Webpack manifest") if site.frontend_manifest.nil?
355
370
 
356
371
  asset_path = if %w(js css).include?(asset_type)
357
372
  site.frontend_manifest["main.#{asset_type}"]
@@ -361,11 +376,40 @@ module Bridgetown
361
376
  end&.last
362
377
  end
363
378
 
364
- return log_webpack_asset_error(site, asset_type) if asset_path.nil?
379
+ return log_frontend_asset_error(site, asset_type) if asset_path.nil?
365
380
 
366
381
  static_frontend_path site, ["js", asset_path]
367
382
  end
368
383
 
384
+ # Return an asset path based on the esbuild manifest file
385
+ # @param site [Bridgetown::Site] The current site object
386
+ # @param asset_type [String] js or css, or filename in manifest
387
+ #
388
+ # @return [String] Returns "MISSING_WEBPACK_MANIFEST" if the manifest
389
+ # file isnt found
390
+ # @return [nil] Returns nil if the asset isnt found
391
+ # @return [String] Returns the path to the asset if no issues parsing
392
+ #
393
+ # @raise [WebpackAssetError] if unable to find css or js in the manifest
394
+ # file
395
+ def parse_esbuild_manifest_file(site, asset_type) # rubocop:disable Metrics/PerceivedComplexity
396
+ return log_frontend_asset_error(site, "esbuild manifest") if site.frontend_manifest.nil?
397
+
398
+ asset_path = if %w(js css).include?(asset_type)
399
+ folder = asset_type == "js" ? "javascript" : "styles"
400
+ site.frontend_manifest["#{folder}/index.#{asset_type}"] ||
401
+ site.frontend_manifest["#{folder}/index.#{asset_type}.rb"]
402
+ else
403
+ site.frontend_manifest.find do |item, _|
404
+ item.sub(%r{^../(frontend/|src/)?}, "") == asset_type
405
+ end&.last
406
+ end
407
+
408
+ return log_frontend_asset_error(site, asset_type) if asset_path.nil?
409
+
410
+ static_frontend_path site, [asset_path]
411
+ end
412
+
369
413
  def static_frontend_path(site, additional_parts = [])
370
414
  path_parts = [
371
415
  site.base_path.gsub(%r(^/|/$), ""),
@@ -376,16 +420,26 @@ module Bridgetown
376
420
  Addressable::URI.parse(path_parts.join("/")).normalize.to_s
377
421
  end
378
422
 
379
- def log_webpack_asset_error(site, asset_type)
380
- site.data[:__webpack_asset_errors] ||= {}
381
- site.data[:__webpack_asset_errors][asset_type] ||=
423
+ def log_frontend_asset_error(site, asset_type)
424
+ site.data[:__frontend_asset_errors] ||= {}
425
+ site.data[:__frontend_asset_errors][asset_type] ||=
382
426
  Bridgetown.logger.warn(
383
- "Webpack:",
427
+ "#{frontend_bundler_type}:",
384
428
  "There was an error parsing your #{asset_type} file. \
385
429
  Please check your #{asset_type} file for any errors."
386
430
  )
387
431
 
388
- "MISSING_WEBPACK_MANIFEST_FILE"
432
+ "MISSING_#{frontend_bundler_type.upcase}_MANIFEST_FILE"
433
+ end
434
+
435
+ def frontend_bundler_type(cwd = Dir.pwd)
436
+ if File.exist?(File.join(cwd, "webpack.config.js"))
437
+ :webpack
438
+ elsif File.exist?(File.join(cwd, "esbuild.config.js"))
439
+ :esbuild
440
+ else
441
+ :unknown
442
+ end
389
443
  end
390
444
 
391
445
  def default_github_branch_name(repo_url)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bridgetown
4
- VERSION = "1.0.0.alpha11"
4
+ VERSION = "1.0.0.beta1"
5
5
  CODE_NAME = "Pearl"
6
6
  end
@@ -4,6 +4,10 @@ module Bridgetown
4
4
  module Watcher
5
5
  extend self
6
6
 
7
+ class << self
8
+ attr_accessor :shutdown
9
+ end
10
+
7
11
  # Continuously watch for file changes and rebuild the site whenever a change is detected.
8
12
  #
9
13
  # @param site [Bridgetown::Site] the current site instance
@@ -15,15 +19,13 @@ module Bridgetown
15
19
 
16
20
  Bridgetown.logger.info "Watcher:", "enabled." unless options[:using_puma]
17
21
 
18
- unless options[:serving]
19
- trap("INT") do
20
- exit 0
21
- end
22
+ return if options[:serving]
22
23
 
23
- sleep_forever
24
+ trap("INT") do
25
+ self.shutdown = true
24
26
  end
25
- rescue ThreadError
26
- # NOTE: not sure if this is needed any longer
27
+
28
+ sleep_forever
27
29
  end
28
30
 
29
31
  # Return a list of load paths which should be watched for changes
@@ -40,11 +42,11 @@ module Bridgetown
40
42
  #
41
43
  # @param (see #watch)
42
44
  def listen(site, options)
43
- webpack_path = site.in_root_dir(".bridgetown-webpack")
44
- FileUtils.mkdir(webpack_path) unless Dir.exist?(webpack_path)
45
+ bundling_path = site.frontend_bundling_path
46
+ FileUtils.mkdir_p(bundling_path)
45
47
  Listen.to(
46
48
  options["source"],
47
- webpack_path,
49
+ bundling_path,
48
50
  *load_paths_to_watch(site, options),
49
51
  ignore: listen_ignore_paths(options),
50
52
  force_polling: options["force_polling"]
@@ -60,40 +62,38 @@ module Bridgetown
60
62
  c.each { |path| Bridgetown.logger.info "", "- #{path["#{site.root_dir}/".length..]}" }
61
63
  end
62
64
 
63
- reload_site(site, options)
65
+ reload_site(site, options, paths: c)
64
66
  end.start
65
67
  end
66
68
 
67
69
  # Reload the site including plugins and Zeitwerk autoloaders and process it (unless SSR)
68
70
  #
69
- # @param (see #watch)
70
- def reload_site(site, options) # rubocop:todo Metrics/MethodLength
71
+ # @param site [Bridgetown::Site] the current site instance
72
+ # @param options [Bridgetown::Configuration] the site configuration
73
+ # @param paths Array<String>
74
+ def reload_site(site, options, paths: []) # rubocop:todo Metrics/MethodLength
71
75
  begin
72
76
  time = Time.now
73
77
  I18n.reload! # make sure any locale files get read again
74
78
  Bridgetown::Current.site = site # needed in SSR mode apparently
75
- Bridgetown::Hooks.trigger :site, :pre_reload, site
76
- Bridgetown::Hooks.clear_reloadable_hooks
77
- site.plugin_manager.reload_plugin_files
78
- site.loaders_manager.reload_loaders
79
- Bridgetown::Hooks.trigger :site, :post_reload, site
80
-
81
- if site.ssr?
82
- site.reset(soft: true)
83
- return
84
- end
85
-
86
- site.process
87
- Bridgetown.logger.info "Done! 🎉", "#{"Completed".green} in less than" \
88
- " #{(Time.now - time).ceil(2)} seconds."
89
- rescue Exception => e
90
- Bridgetown.logger.error "Error:", e.message
79
+ catch :halt do
80
+ Bridgetown::Hooks.trigger :site, :pre_reload, site, paths
81
+ Bridgetown::Hooks.clear_reloadable_hooks
82
+ site.plugin_manager.reload_plugin_files
83
+ site.loaders_manager.reload_loaders
84
+ Bridgetown::Hooks.trigger :site, :post_reload, site, paths
85
+
86
+ if site.ssr?
87
+ site.reset(soft: true)
88
+ return
89
+ end
91
90
 
92
- if options[:trace]
93
- Bridgetown.logger.info e.backtrace.join("\n")
94
- else
95
- Bridgetown.logger.warn "Backtrace:", "Use the --trace option for more information."
91
+ site.process
96
92
  end
93
+ Bridgetown.logger.info "Done! 🎉", "#{"Completed".bold.green} in less than" \
94
+ " #{(Time.now - time).ceil(2)} seconds."
95
+ rescue StandardError => e
96
+ Bridgetown::Errors.print_build_error(e, trace: options[:trace])
97
97
  end
98
98
  Bridgetown.logger.info ""
99
99
  end
@@ -155,7 +155,7 @@ module Bridgetown
155
155
  end
156
156
 
157
157
  def sleep_forever
158
- loop { sleep 1000 }
158
+ sleep 0.5 until shutdown
159
159
  end
160
160
  end
161
161
  end
@@ -268,3 +268,4 @@ loader = Zeitwerk::Loader.new
268
268
  loader.push_dir File.join(__dir__, "bridgetown-core/model"), namespace: Bridgetown::Model
269
269
  loader.push_dir File.join(__dir__, "bridgetown-core/resource"), namespace: Bridgetown::Resource
270
270
  loader.setup # ready!
271
+ Bridgetown::Model::Origin # this needs to load first
@@ -1,23 +1,29 @@
1
1
  source "https://rubygems.org"
2
2
  git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
3
 
4
- # Hello! This is where you manage which Bridgetown version is used to run.
5
- # When you want to use a different version, change it below, save the
6
- # file and run `bundle install`. Run Bridgetown like so:
4
+ ####
5
+ # Welcome to your project's Gemfile, used by Rubygems & Bundler.
7
6
  #
8
- # bin/bridgetown start (or console, etc.)
7
+ # To install a plugin, run:
9
8
  #
10
- # This will help ensure the proper Bridgetown version is running.
9
+ # bundle add new-plugin-name -g bridgetown_plugins
10
+ #
11
+ # This will ensure the plugin is added to the correct Bundler group.
11
12
  #
12
- # To install a plugin, simply run bundle add and specify the group
13
- # "bridgetown_plugins". For example:
13
+ # When you run Bridgetown commands, we recommend using a binstub like so:
14
14
  #
15
- # bundle add some-new-plugin -g bridgetown_plugins
15
+ # bin/bridgetown start (or console, etc.)
16
16
  #
17
- # Happy Bridgetowning!
17
+ # This will help ensure the proper Bridgetown version is running.
18
+ ####
18
19
 
20
+ # If you need to upgrade/switch Bridgetown versions, change the line below
21
+ # and then run `bundle update bridgetown`
19
22
  gem "bridgetown", "~> <%= Bridgetown::VERSION %>"
20
23
 
21
- # Puma is a Rack-compatible server
24
+ # Uncomment to add file-based dynamic routing to your project:
25
+ # gem "bridgetown-routes", "~> <%= Bridgetown::VERSION %>", group: :bridgetown_plugins
26
+
27
+ # Puma is a Rack-compatible server used by Bridgetown
22
28
  # (you can optionally limit this to the "development" group)
23
- gem "puma", "~> 5.2"
29
+ gem "puma", "~> 5.5"
@@ -35,7 +35,7 @@ bundle install && yarn install
35
35
 
36
36
  To start your site in development mode, run `bin/bridgetown start` and navigate to [localhost:4000](https://localhost:4000/)!
37
37
 
38
- Use a [theme](https://github.com/topics/bridgetown-theme), add some [plugins](https://www.bridgetownrb.com/plugins/), and/or run some [automations](https://github.com/topics/bridgetown-automation) to get started quickly.
38
+ Use a [theme](https://github.com/topics/bridgetown-theme) or add some [plugins](https://www.bridgetownrb.com/plugins/) to get started quickly.
39
39
 
40
40
  ### Commands
41
41
 
@@ -54,7 +54,7 @@ bin/bridgetown console
54
54
 
55
55
  ## Deployment
56
56
 
57
- You can deploy Bridgetown sites on "Jamstack" hosts (Netlify, Vercel, Render, etc.) or virtually any tranditional web server by simply building and copying the output folder to your HTML root.
57
+ You can deploy Bridgetown sites on hosts like Render or Vercel as well as tranditional web servers by simply building and copying the output folder to your HTML root.
58
58
 
59
59
  > Read the [Bridgetown Deployment Documentation](https://www.bridgetownrb.com/docs/deployment) for more information.
60
60
 
@@ -24,6 +24,20 @@ task :clean do
24
24
  Bridgetown::Commands::Clean.start
25
25
  end
26
26
 
27
+ <%- if frontend_bundling_option == "esbuild" -%>
28
+ namespace :frontend do
29
+ desc "Build the frontend with esbuild for deployment"
30
+ task :build do
31
+ sh "yarn run esbuild"
32
+ end
33
+
34
+ desc "Watch the frontend with esbuild during development"
35
+ task :dev do
36
+ sh "yarn run esbuild-dev"
37
+ rescue Interrupt
38
+ end
39
+ end
40
+ <%- else -%>
27
41
  namespace :frontend do
28
42
  desc "Build the frontend with Webpack for deployment"
29
43
  task :build do
@@ -36,6 +50,7 @@ namespace :frontend do
36
50
  rescue Interrupt
37
51
  end
38
52
  end
53
+ <%- end -%>
39
54
 
40
55
  #
41
56
  # Add your own Rake tasks here! You can use `environment` as a prerequisite
@@ -0,0 +1,11 @@
1
+ <header>
2
+ <img src="/images/logo.svg" alt="Logo" />
3
+ </header>
4
+
5
+ <nav>
6
+ <ul>
7
+ <li><a href="/">Home</a></li>
8
+ <li><a href="/about">About</a></li>
9
+ <li><a href="/posts">Posts</a></li>
10
+ </ul>
11
+ </nav>
@@ -0,0 +1,5 @@
1
+ class Shared::Navbar < Bridgetown::Component
2
+ def initialize(metadata:, resource:)
3
+ @metadata, @resource = metadata, resource
4
+ end
5
+ end
@@ -0,0 +1,15 @@
1
+ <!doctype html>
2
+ <html lang="<%= site.locale %>">
3
+ <head>
4
+ <%= render "head", metadata: site.metadata, title: resource.data.title %>
5
+ </head>
6
+ <body class="<%= resource.data.layout %> <%= resource.data.page_class %>">
7
+ <%= render Shared::Navbar.new(metadata: site.metadata, resource: resource) %>
8
+
9
+ <main>
10
+ <%= yield %>
11
+ </main>
12
+
13
+ <%= render "footer", metadata: site.metadata %>
14
+ </body>
15
+ </html>
@@ -0,0 +1,7 @@
1
+ ---
2
+ layout: default
3
+ ---
4
+
5
+ <h1><%= resource.data.title %></h1>
6
+
7
+ <%= yield %>
@@ -0,0 +1,7 @@
1
+ ---
2
+ layout: default
3
+ ---
4
+
5
+ <h1><%= resource.data.title %></h1>
6
+
7
+ <%= yield %>
@@ -0,0 +1,3 @@
1
+ <footer>
2
+ Contact me at <a href="mailto:<%= metadata.email %>"><%= metadata.email %></a>
3
+ </footer>
@@ -0,0 +1,10 @@
1
+ <meta charset="utf-8" />
2
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
3
+ <% resource_title = strip_html(strip_newlines(title)) %>
4
+ <title><% if resource_title != "Index" %><%= resource_title %> | <%= metadata.title %><% else %><%= metadata.title %>: <%= metadata.tagline %><% end %></title>
5
+
6
+ <meta name="description" content="<%= metadata.description %>" />
7
+
8
+ <link rel="stylesheet" href="<%= webpack_path :css %>" />
9
+ <script src="<%= webpack_path :js %>" defer></script>
10
+ <%= live_reload_dev_js %>
@@ -0,0 +1,10 @@
1
+ <meta charset="utf-8" />
2
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
3
+ {% capture resource_title %}{{ title | strip_html | strip_newlines }}{% endcapture %}
4
+ <title>{% if resource_title != "Index" %}{{ resource_title | escape }} | {{ metadata.title | escape }}{% else %}{{ metadata.title | escape }}: {{ metadata.tagline | escape }}{% endif %}</title>
5
+
6
+ <meta name="description" content="{{ metadata.description }}" />
7
+
8
+ <link rel="stylesheet" href="{% asset_path css %}" />
9
+ <script src="{% asset_path js %}" defer></script>
10
+ {% live_reload_dev_js %}
@@ -0,0 +1,11 @@
1
+ <header>
2
+ <img src="/images/logo.svg" alt="Logo" />
3
+ </header>
4
+
5
+ <nav>
6
+ <ul>
7
+ <li><a href="/">Home</a></li>
8
+ <li><a href="/about">About</a></li>
9
+ <li><a href="/posts">Posts</a></li>
10
+ </ul>
11
+ </nav>
@@ -3,8 +3,8 @@
3
3
  <head>
4
4
  {% render "head", metadata: site.metadata, title: page.title %}
5
5
  </head>
6
- <body class="{{ page.layout }} {{ page.page_class }}">
7
- {% render "navbar", metadata: site.metadata, page: page %}
6
+ <body class="{{ resource.data.layout }} {{ resource.data.page_class }}">
7
+ {% render "navbar", metadata: site.metadata, resource: resource %}
8
8
 
9
9
  <main>
10
10
  {{ content }}
@@ -0,0 +1,5 @@
1
+ class Shared::Navbar < Bridgetown::Component
2
+ def initialize(metadata:, resource:)
3
+ @metadata, @resource = metadata, resource
4
+ end
5
+ end
@@ -0,0 +1,11 @@
1
+ <header>
2
+ <img src="/images/logo.svg" alt="Logo" />
3
+ </header>
4
+
5
+ <nav>
6
+ <ul>
7
+ <li><a href="/">Home</a></li>
8
+ <li><a href="/about">About</a></li>
9
+ <li><a href="/posts">Posts</a></li>
10
+ </ul>
11
+ </nav>
@@ -0,0 +1,15 @@
1
+ <!doctype html>
2
+ <html lang="{%= site.locale %}">
3
+ <head>
4
+ {%@ "head", metadata: site.metadata, title: resource.data.title %}
5
+ </head>
6
+ <body class="{{ resource.data.layout }} {{ resource.data.page_class }}">
7
+ {%@ Shared::Navbar metadata: site.metadata, resource: resource %}
8
+
9
+ <main>
10
+ {%= yield %}
11
+ </main>
12
+
13
+ {%@ "footer", metadata: site.metadata %}
14
+ </body>
15
+ </html>
@@ -0,0 +1,7 @@
1
+ ---
2
+ layout: default
3
+ ---
4
+
5
+ <h1>{{ resource.data.title }}</h1>
6
+
7
+ {%= yield %}
@@ -0,0 +1,7 @@
1
+ ---
2
+ layout: default
3
+ ---
4
+
5
+ <h1>{{ resource.data.title }}</h1>
6
+
7
+ {%= yield %}
@@ -0,0 +1,3 @@
1
+ <footer>
2
+ Contact me at <a href="mailto:{{ metadata.email }}">{{ metadata.email }}</a>
3
+ </footer>
@@ -0,0 +1,10 @@
1
+ <meta charset="utf-8" />
2
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
3
+ {{ title | strip_html | strip_newlines | assign_to: :resource_title }}
4
+ <title>{% if @resource_title != "Index" %}{{ @resource_title }} | {{ metadata.title }}{% else %}{{ metadata.title }}: {{ metadata.tagline }}{% end %}</title>
5
+
6
+ <meta name="description" content="{%= metadata.description %}" />
7
+
8
+ <link rel="stylesheet" href="{%= webpack_path :css %}" />
9
+ <script src="{%= webpack_path :js %}" defer></script>
10
+ {%= live_reload_dev_js %}
@@ -1,11 +1,15 @@
1
- <%- if options["use-postcss"] -%>
1
+ <%- if postcss_option -%>
2
2
  import "index.css"
3
3
  <%- else -%>
4
4
  import "index.scss"
5
5
  <%- end -%>
6
6
 
7
- // Import all javascript files from src/_components
8
- const componentsContext = require.context("bridgetownComponents", true, /.js$/)
7
+ // Import all JavaScript & CSS files from src/_components
8
+ <%- if frontend_bundling_option == "esbuild" -%>
9
+ import components from "bridgetownComponents/**/*.{js,jsx,js.rb,css}"
10
+ <%- else -%>
11
+ const componentsContext = require.context("bridgetownComponents", true, /\.(js|css)$/)
9
12
  componentsContext.keys().forEach(componentsContext)
13
+ <%- end -%>
10
14
 
11
15
  console.info("Bridgetown is loaded!")