streaming single conversation, this is sick
This commit is contained in:
3
lib/elixir_ai_web/components/layouts/app.html.heex
Normal file
3
lib/elixir_ai_web/components/layouts/app.html.heex
Normal file
@@ -0,0 +1,3 @@
|
||||
<main class="px-4 py-8 sm:px-6 lg:px-8">
|
||||
{@inner_content}
|
||||
</main>
|
||||
23
lib/elixir_ai_web/components/markdown.ex
Normal file
23
lib/elixir_ai_web/components/markdown.ex
Normal file
@@ -0,0 +1,23 @@
|
||||
defmodule ElixirAiWeb.Markdown do
|
||||
@doc """
|
||||
Converts a markdown string to sanitized HTML, safe for raw rendering.
|
||||
Falls back to escaped plain text if the markdown is incomplete or invalid.
|
||||
"""
|
||||
def render(nil), do: Phoenix.HTML.raw("")
|
||||
def render(""), do: Phoenix.HTML.raw("")
|
||||
|
||||
def render(markdown) do
|
||||
case Earmark.as_html(markdown, breaks: true, compact_output: true) do
|
||||
{:ok, html, _warnings} ->
|
||||
html
|
||||
|> HtmlSanitizeEx.markdown_html()
|
||||
|> Phoenix.HTML.raw()
|
||||
|
||||
{:error, html, _errors} ->
|
||||
# Partial/invalid markdown — use whatever HTML was produced, still sanitize
|
||||
html
|
||||
|> HtmlSanitizeEx.markdown_html()
|
||||
|> Phoenix.HTML.raw()
|
||||
end
|
||||
end
|
||||
end
|
||||
11
lib/elixir_ai_web/components/spinner.ex
Normal file
11
lib/elixir_ai_web/components/spinner.ex
Normal file
@@ -0,0 +1,11 @@
|
||||
defmodule ElixirAiWeb.Spinner do
|
||||
use Phoenix.Component
|
||||
|
||||
attr :class, :string, default: nil
|
||||
|
||||
def spinner(assigns) do
|
||||
~H"""
|
||||
<span class={["loader", @class]}></span>
|
||||
"""
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user