defmodule AshHqWeb.Components.Forum.Attachment do @moduledoc "Renders an attachment" use Surface.Component prop(attachment, :any, required: true) def render(assigns) do ~F"""
{#case video_type(@attachment.filename)} {#match {:video, mime}} {#match {:image, _mime}} {#match _} other {/case}
""" end defp video_type(path) do mime = MIME.from_path(path) case mime do "image/" <> _ -> {:image, mime} "video/" <> _ -> {:video, mime} _ -> {:other, mime} end end end