prop/lib/microwaveprop_web/live/algo_live.ex
Graham McIntire 166f95e29d
Embed algo.md at compile time to fix prod 500
algo.md was read at runtime via File.read! but isn't included in
the release. Use @external_resource + compile-time module attribute
to bake the HTML into the module.
2026-03-31 12:51:40 -05:00

26 lines
649 B
Elixir

defmodule MicrowavepropWeb.AlgoLive do
@moduledoc false
use MicrowavepropWeb, :live_view
@external_resource "algo.md"
@algo_html "algo.md" |> File.read!() |> Earmark.as_html!()
@impl true
def mount(_params, _session, socket) do
{:ok, assign(socket, page_title: "Algorithm", content: @algo_html)}
end
@impl true
def render(assigns) do
~H"""
<div class="markdown-content">
<div class="mb-4">
<.link navigate="/map" class="btn btn-lg btn-ghost text-lg">
<.icon name="hero-arrow-left" class="size-4" /> Back to map
</.link>
</div>
{raw(@content)}
</div>
"""
end
end