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:
parent
40d1fa03aa
commit
166f95e29d
1 changed files with 3 additions and 7 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue