Skip to content

Commit

Permalink
Update components (BeaconCMS#513)
Browse files Browse the repository at this point in the history
  • Loading branch information
leandrocp authored Jun 6, 2024
1 parent 7073e58 commit 5dff82f
Show file tree
Hide file tree
Showing 28 changed files with 790 additions and 856 deletions.
2 changes: 1 addition & 1 deletion .credo.exs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
{Credo.Check.Refactor.MapJoin, []},
{Credo.Check.Refactor.NegatedConditionsInUnless, []},
{Credo.Check.Refactor.NegatedConditionsWithElse, []},
{Credo.Check.Refactor.Nesting, []},
{Credo.Check.Refactor.Nesting, [max_nesting: 3]},
{Credo.Check.Refactor.UnlessWithElse, []},
{Credo.Check.Refactor.WithClauses, []},
{Credo.Check.Refactor.FilterFilter, []},
Expand Down
11 changes: 7 additions & 4 deletions dev.exs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ dev_seeds = fn ->
<li>
<%= @val %>
</li>
"""
""",
example: "<.sample_component val={1} />"
})

Beacon.Content.create_snippet_helper!(%{
Expand Down Expand Up @@ -256,7 +257,7 @@ dev_seeds = fn ->
</div>
<div>
<BeaconWeb.Components.image_set asset={@img1} sources={["480w"]} width="200px" />
<%!-- <BeaconWeb.Components.image_set asset={@img1} sources={["480w"]} width="200px" /> --%>
</div>
<div>
Expand Down Expand Up @@ -433,7 +434,8 @@ dy_seeds = fn ->
</div>
</nav>
</header>
"""
""",
example: "<.header />"
})

Beacon.Content.create_component!(%{
Expand Down Expand Up @@ -717,7 +719,8 @@ dy_seeds = fn ->
</div>
</div>
</footer>
"""
""",
example: "<.footer />"
})

layout =
Expand Down
4 changes: 2 additions & 2 deletions guides/your-first-site.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ Edit the template to replace with this content:
</span>
</div>
<div class="flex items-center justify-center">
<BeaconWeb.Components.image
<.image
name="image.webp"
alt="My Page Image"
width="600"
Expand Down Expand Up @@ -334,7 +334,7 @@ Now let's upload an image on the Media Library to finish our home page. Go to ht
Once it's uploaded, note the image will be converted to a webp format for performance reasons, for example uploading a file logo.jpg it will be converted to logo.webp and we must use the new name on our template. Take note of the file name you just uploaded and edit the home page template, look for the image component `BeaconWeb.Components.image` in the template and update the name attribute:

```heex
<BeaconWeb.Components.image
<.image
name="my_image.webp"
...
```
Expand Down
6 changes: 4 additions & 2 deletions lib/beacon/beacon.ex
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,10 @@ defmodule Beacon do
"""
@spec boot(Beacon.Types.Site.t()) :: :ok
def boot(site) do
Beacon.Boot.do_init(Config.fetch!(site))
Beacon.Config.update_value(site, :skip_boot?, false)
site
|> Config.fetch!()
|> Beacon.Boot.do_init()

:ok
end

Expand Down
8 changes: 3 additions & 5 deletions lib/beacon/boot.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ defmodule Beacon.Boot do
def do_init(config) do
Logger.info("Beacon.Boot booting site #{config.site}")

task_supervisor = task_supervisor(config.site)
task_supervisor = Beacon.Registry.via({config.site, TaskSupervisor})

# Layouts and pages depend on the components module so we need to load it first
Beacon.Loader.populate_default_components(config.site)
Expand Down Expand Up @@ -57,13 +57,11 @@ defmodule Beacon.Boot do
# TODO: revisit this timeout after we upgrade to Tailwind v4
Task.await_many(assets, :timer.minutes(5))

Beacon.Config.update_value(config.site, :skip_boot?, false)

# TODO: add telemetry to measure booting time
Logger.info("Beacon.Boot finished booting site #{config.site}")

:ignore
end

defp task_supervisor(site) do
Beacon.Registry.via({site, TaskSupervisor})
end
end
Loading

0 comments on commit 5dff82f

Please sign in to comment.