bridgetown-core 1.0.0.alpha10 → 1.0.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) 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/collection.rb +6 -6
  6. data/lib/bridgetown-core/commands/base.rb +18 -18
  7. data/lib/bridgetown-core/commands/build.rb +1 -1
  8. data/lib/bridgetown-core/commands/clean.rb +2 -2
  9. data/lib/bridgetown-core/commands/console.rb +1 -0
  10. data/lib/bridgetown-core/commands/esbuild/esbuild.config.js +27 -0
  11. data/lib/bridgetown-core/commands/esbuild/esbuild.defaults.js.erb +216 -0
  12. data/lib/bridgetown-core/commands/esbuild/migrate-from-webpack.rb +47 -0
  13. data/lib/bridgetown-core/commands/esbuild/setup.rb +4 -0
  14. data/lib/bridgetown-core/commands/esbuild/update.rb +4 -0
  15. data/lib/bridgetown-core/commands/esbuild.rb +83 -0
  16. data/lib/bridgetown-core/commands/new.rb +80 -10
  17. data/lib/bridgetown-core/commands/webpack/enable-postcss.rb +1 -1
  18. data/lib/bridgetown-core/commands/webpack/update.rb +3 -3
  19. data/lib/bridgetown-core/commands/webpack/webpack.defaults.js.erb +1 -1
  20. data/lib/bridgetown-core/commands/webpack.rb +3 -3
  21. data/lib/bridgetown-core/component.rb +9 -3
  22. data/lib/bridgetown-core/concerns/site/configurable.rb +6 -0
  23. data/lib/bridgetown-core/concerns/site/content.rb +4 -4
  24. data/lib/bridgetown-core/concerns/site/extensible.rb +8 -0
  25. data/lib/bridgetown-core/concerns/site/processable.rb +23 -4
  26. data/lib/bridgetown-core/concerns/site/renderable.rb +27 -16
  27. data/lib/bridgetown-core/concerns/site/ssr.rb +2 -17
  28. data/lib/bridgetown-core/concerns/transformable.rb +62 -0
  29. data/lib/bridgetown-core/configurations/minitesting.rb +1 -1
  30. data/lib/bridgetown-core/configurations/purgecss.rb +2 -1
  31. data/lib/bridgetown-core/configurations/render/render.yaml.erb +3 -0
  32. data/lib/bridgetown-core/configurations/stimulus.rb +41 -12
  33. data/lib/bridgetown-core/configurations/tailwindcss/css_imports.css +5 -0
  34. data/lib/bridgetown-core/configurations/tailwindcss.rb +31 -2
  35. data/lib/bridgetown-core/configurations/turbo/turbo_transitions.js +48 -0
  36. data/lib/bridgetown-core/configurations/turbo.rb +15 -5
  37. data/lib/bridgetown-core/configurations/vercel/vercel.json +45 -0
  38. data/lib/bridgetown-core/configurations/vercel/vercel_url.rb +12 -0
  39. data/lib/bridgetown-core/configurations/vercel.rb +4 -0
  40. data/lib/bridgetown-core/converters/erb_templates.rb +6 -8
  41. data/lib/bridgetown-core/converters/ruby_templates.rb +1 -1
  42. data/lib/bridgetown-core/converters/serbea_templates.rb +5 -8
  43. data/lib/bridgetown-core/drops/drop.rb +1 -1
  44. data/lib/bridgetown-core/drops/resource_drop.rb +28 -5
  45. data/lib/bridgetown-core/errors.rb +21 -0
  46. data/lib/bridgetown-core/generated_page.rb +81 -17
  47. data/lib/bridgetown-core/generators/prototype_generator.rb +3 -3
  48. data/lib/bridgetown-core/helpers.rb +3 -2
  49. data/lib/bridgetown-core/hooks.rb +51 -20
  50. data/lib/bridgetown-core/model/base.rb +24 -1
  51. data/lib/bridgetown-core/model/origin.rb +4 -6
  52. data/lib/bridgetown-core/model/repo_origin.rb +48 -0
  53. data/lib/bridgetown-core/rack/boot.rb +5 -9
  54. data/lib/bridgetown-core/rack/roda.rb +4 -5
  55. data/lib/bridgetown-core/rack/routes.rb +44 -10
  56. data/lib/bridgetown-core/rack/static_indexes.rb +2 -0
  57. data/lib/bridgetown-core/resource/base.rb +3 -1
  58. data/lib/bridgetown-core/resource/transformer.rb +21 -85
  59. data/lib/bridgetown-core/ruby_template_view.rb +11 -0
  60. data/lib/bridgetown-core/site.rb +5 -0
  61. data/lib/bridgetown-core/tags/{webpack_path.rb → asset_path.rb} +7 -9
  62. data/lib/bridgetown-core/tasks/bridgetown_tasks.rake +2 -1
  63. data/lib/bridgetown-core/utils/loaders_manager.rb +6 -0
  64. data/lib/bridgetown-core/utils.rb +88 -30
  65. data/lib/bridgetown-core/version.rb +1 -1
  66. data/lib/bridgetown-core/watcher.rb +74 -70
  67. data/lib/bridgetown-core.rb +2 -1
  68. data/lib/site_template/Gemfile.erb +17 -11
  69. data/lib/site_template/README.md +2 -2
  70. data/lib/site_template/{Rakefile → Rakefile.erb} +15 -0
  71. data/lib/site_template/TEMPLATES/erb/_components/shared/navbar.erb +11 -0
  72. data/lib/site_template/TEMPLATES/erb/_components/shared/navbar.rb +5 -0
  73. data/lib/site_template/TEMPLATES/erb/_layouts/default.erb +15 -0
  74. data/lib/site_template/TEMPLATES/erb/_layouts/page.erb +7 -0
  75. data/lib/site_template/TEMPLATES/erb/_layouts/post.erb +7 -0
  76. data/lib/site_template/TEMPLATES/erb/_partials/_footer.erb +3 -0
  77. data/lib/site_template/TEMPLATES/erb/_partials/_head.erb +10 -0
  78. data/lib/site_template/{src → TEMPLATES/liquid}/_components/footer.liquid +0 -0
  79. data/lib/site_template/TEMPLATES/liquid/_components/head.liquid +10 -0
  80. data/lib/site_template/TEMPLATES/liquid/_components/navbar.liquid +11 -0
  81. data/lib/site_template/{src → TEMPLATES/liquid}/_layouts/default.liquid +2 -2
  82. data/lib/site_template/{src → TEMPLATES/liquid}/_layouts/page.liquid +0 -0
  83. data/lib/site_template/{src → TEMPLATES/liquid}/_layouts/post.liquid +0 -0
  84. data/lib/site_template/TEMPLATES/serbea/_components/shared/navbar.rb +5 -0
  85. data/lib/site_template/TEMPLATES/serbea/_components/shared/navbar.serb +11 -0
  86. data/lib/site_template/TEMPLATES/serbea/_layouts/default.serb +15 -0
  87. data/lib/site_template/TEMPLATES/serbea/_layouts/page.serb +7 -0
  88. data/lib/site_template/TEMPLATES/serbea/_layouts/post.serb +7 -0
  89. data/lib/site_template/TEMPLATES/serbea/_partials/_footer.serb +3 -0
  90. data/lib/site_template/TEMPLATES/serbea/_partials/_head.serb +10 -0
  91. data/lib/site_template/frontend/javascript/index.js.erb +7 -3
  92. data/lib/site_template/frontend/styles/index.css +71 -6
  93. data/lib/site_template/package.json.erb +24 -9
  94. data/lib/site_template/ruby-version.erb +1 -0
  95. data/lib/site_template/server/roda_app.rb +5 -3
  96. data/lib/site_template/server/routes/hello.rb.sample +1 -1
  97. data/lib/site_template/src/images/logo.svg +91 -0
  98. data/lib/site_template/src/index.md.erb +22 -0
  99. data/lib/site_template/src/posts.md.erb +28 -0
  100. metadata +57 -23
  101. data/lib/bridgetown-core/configurations/swup.rb +0 -37
  102. data/lib/bridgetown-core/renderer.rb +0 -169
  103. data/lib/site_template/frontend/styles/index.scss +0 -17
  104. data/lib/site_template/src/_components/head.liquid +0 -10
  105. data/lib/site_template/src/_components/navbar.liquid +0 -5
  106. data/lib/site_template/src/_layouts/home.liquid +0 -7
  107. data/lib/site_template/src/images/.keep +0 -1
  108. data/lib/site_template/src/index.md +0 -7
  109. data/lib/site_template/src/posts.md +0 -14
@@ -1,169 +0,0 @@
1
- # frozen_string_literal: true
2
-
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
6
- class Renderer
7
- attr_reader :document, :site
8
-
9
- def initialize(site, document)
10
- @site = site
11
- @document = document
12
- end
13
-
14
- # Determine which converters to use based on this document's
15
- # extension.
16
- #
17
- # Returns Array of Converter instances.
18
- def converters
19
- @converters ||= site.converters.select do |converter|
20
- if converter.method(:matches).arity == 1
21
- converter.matches(document.extname)
22
- else
23
- converter.matches(document.extname, document)
24
- end
25
- end.sort
26
- end
27
-
28
- # Determine the extname the outputted file should have
29
- #
30
- # Returns String the output extname including the leading period.
31
- def output_ext
32
- @output_ext ||= (permalink_ext || converter_output_ext)
33
- end
34
-
35
- # Run hooks and render the document
36
- #
37
- # Returns nothing
38
- def run
39
- Bridgetown.logger.debug "Rendering:", document.relative_path
40
-
41
- document.trigger_hooks :pre_render
42
- document.output = render_document
43
- document.trigger_hooks :post_render
44
- end
45
-
46
- # Render the document.
47
- #
48
- # Returns String rendered document output
49
- def render_document
50
- execute_inline_ruby!
51
-
52
- output = document.content
53
- Bridgetown.logger.debug "Rendering Markup:", document.relative_path
54
- output = convert(output.to_s, document)
55
- document.content = output.html_safe
56
-
57
- if document.place_in_layout?
58
- Bridgetown.logger.debug "Rendering Layout:", document.relative_path
59
- output = place_in_layouts(output)
60
- end
61
-
62
- output
63
- end
64
-
65
- def execute_inline_ruby!
66
- return unless site.config.should_execute_inline_ruby?
67
-
68
- Bridgetown::Utils::RubyExec.search_data_for_ruby_code(document)
69
- end
70
-
71
- # Convert the document using the converters which match this renderer's document.
72
- #
73
- # Returns String the converted content.
74
- def convert(content, document)
75
- converters.reduce(content) do |output, converter|
76
- if converter.method(:convert).arity == 1
77
- converter.convert output
78
- else
79
- converter.convert output, document
80
- end
81
- rescue StandardError => e
82
- Bridgetown.logger.error "Conversion error:",
83
- "#{converter.class} encountered an error while "\
84
- "converting `#{document.relative_path}'"
85
- raise e
86
- end
87
- end
88
-
89
- # Render layouts and place document content inside.
90
- #
91
- # Returns String rendered content
92
- def place_in_layouts(content)
93
- output = content.dup
94
- layout = site.layouts[document.data["layout"]]
95
- validate_layout(layout)
96
-
97
- used = Set.new([layout])
98
-
99
- while layout
100
- output = render_layout(output, layout)
101
-
102
- next unless (layout = site.layouts[layout.data["layout"]])
103
- break if used.include?(layout)
104
-
105
- used << layout
106
- end
107
- output
108
- end
109
-
110
- private
111
-
112
- # Checks if the layout specified in the document actually exists
113
- #
114
- # layout - the layout to check
115
- # Returns nothing
116
- def validate_layout(layout)
117
- return unless document.data["layout"].present? &&
118
- layout.nil? &&
119
- !(document.is_a? Bridgetown::Excerpt)
120
-
121
- Bridgetown.logger.warn "Build Warning:", "Layout '#{document.data["layout"]}' requested " \
122
- "in #{document.relative_path} does not exist."
123
- end
124
-
125
- # Render layout content into document.output
126
- #
127
- # Returns String rendered content
128
- def render_layout(output, layout)
129
- layout_converters = site.matched_converters_for_convertible(layout)
130
-
131
- layout_content = layout.content.dup
132
- layout_converters.reduce(layout_content) do |layout_output, converter|
133
- next(layout_output) unless converter.method(:convert).arity == 2
134
-
135
- layout.current_document = document
136
- layout.current_document_output = output
137
- converter.convert layout_output, layout
138
- rescue StandardError => e
139
- Bridgetown.logger.error "Conversion error:",
140
- "#{converter.class} encountered an error while "\
141
- "converting `#{document.relative_path}'"
142
- raise e
143
- end
144
- end
145
-
146
- def permalink_ext
147
- document_permalink = document.permalink
148
- if document_permalink &&
149
- !document_permalink.end_with?("/")
150
- permalink_ext = File.extname(document_permalink)
151
- permalink_ext unless permalink_ext.empty?
152
- end
153
- end
154
-
155
- def converter_output_ext
156
- if output_exts.size == 1
157
- output_exts.last
158
- else
159
- output_exts[-2]
160
- end
161
- end
162
-
163
- def output_exts
164
- @output_exts ||= converters.filter_map do |c|
165
- c.output_ext(document.extname)
166
- end
167
- end
168
- end
169
- end
@@ -1,17 +0,0 @@
1
- $body-background: #fafafa;
2
- $body-color: #444;
3
-
4
- body {
5
- background: $body-background;
6
- color: $body-color;
7
- font-family: sans-serif;
8
- }
9
-
10
- h1, nav, footer {
11
- text-align: center;
12
- }
13
-
14
- main {
15
- margin: 4rem auto;
16
- max-width: 60rem;
17
- }
@@ -1,10 +0,0 @@
1
- <meta charset="utf-8" />
2
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
3
- {% capture page_title %}{{ title | strip_html | strip_newlines }}{% endcapture %}
4
- <title>{% if page_title != "Index" %}{{ page_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="{% webpack_path css %}" />
9
- <script src="{% webpack_path js %}" defer></script>
10
- {% live_reload_dev_js %}
@@ -1,5 +0,0 @@
1
- <nav>
2
- <a href="/">Home</a>
3
- <a href="/about">About</a>
4
- <a href="/posts">Posts</a>
5
- </nav>
@@ -1,7 +0,0 @@
1
- ---
2
- layout: default
3
- ---
4
-
5
- <h1>Home Page</h1>
6
-
7
- {{ content }}
@@ -1 +0,0 @@
1
-
@@ -1,7 +0,0 @@
1
- ---
2
- # Feel free to add content and custom Front Matter to this file.
3
-
4
- layout: home
5
- ---
6
-
7
- Welcome to Bridgetown!
@@ -1,14 +0,0 @@
1
- ---
2
- layout: page
3
- title: Posts
4
- ---
5
-
6
- <ul>
7
- {% for post in collections.posts.resources %}
8
- <li>
9
- <a href="{{ post.relative_url }}">{{ post.title }}</a>
10
- </li>
11
- {% endfor %}
12
- </ul>
13
-
14
- If you have a lot of posts, you may want to consider adding [pagination](https://www.bridgetownrb.com/docs/content/pagination)!