# ExPress
Use markdown folders as a source for page content.
Cache on *write* and serve from ETS.
TODO: Write proper readme
## Setup
Add it to your deps in `mix.exs`
```elixir
{:ex_press, "~> 0.0.13"},
```
Point it to the directory with your markdown files.
```elixir
# config/runtime.ex
config :ex_press, ExPress.Store,
directory: "path/to/content/folder"
```
```elixir
defmodule MyAppWeb.PageLive.Show do
use MyAppWeb, :live_view
@impl true
def render(assigns) do
~H"""
<main>
{@page.html |> raw()}
</main>
"""
end
@impl true
def handle_params(%{"slug" => slug}, uri, socket) do
# or use ExPress.get_by_slug(slug, true) to bypass ETS cache.
case ExPress.get_by_slug(slug) do
{:ok, page} ->
{:noreply, socket
|> assign(page: page)
|> assign(page_title: page.metadata["title"] || "Untitled")
# Get all pages in the store:
|> assign(pages: ExPress.Store.list_contents())
}
:error ->
{:noreply,
socket
|> put_flash(:error, "Page not found: #{slug}")
|> push_navigate(to: "/")}
end
end
end
```
And mount it in your router
```elixir
# lib/my_app_web/router.ex
live "/*slug", PageLive.Show
```