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.
This commit is contained in:
Graham McIntire 2026-03-31 12:51:40 -05:00
parent 40d1fa03aa
commit 166f95e29d
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59

View file

@ -2,16 +2,12 @@ defmodule MicrowavepropWeb.AlgoLive do
@moduledoc false
use MicrowavepropWeb, :live_view
@algo_path Path.join(:code.priv_dir(:microwaveprop), "../algo.md")
@external_resource "algo.md"
@algo_html "algo.md" |> File.read!() |> Earmark.as_html!()
@impl true
def mount(_params, _session, socket) do
content =
@algo_path
|> File.read!()
|> Earmark.as_html!()
{:ok, assign(socket, page_title: "Algorithm", content: content)}
{:ok, assign(socket, page_title: "Algorithm", content: @algo_html)}
end
@impl true