diff --git a/assets/css/app.css b/assets/css/app.css
index 732322d..de7531d 100644
--- a/assets/css/app.css
+++ b/assets/css/app.css
@@ -14,8 +14,7 @@
/* daisyUI Tailwind Plugin. You can update this file by fetching the latest version with:
curl -sLO https://github.com/saadeghi/daisyui/releases/latest/download/daisyui.js
Make sure to look at the daisyUI changelog: https://daisyui.com/docs/changelog/ */
-@plugin "../vendor/daisyui" {
-}
+@plugin "../vendor/daisyui" {}
@source inline("mr-1");
@source inline("mb-2");
@@ -80,7 +79,6 @@ a {
overflow-wrap: anywhere;
}
-/* This file is for your main application CSS */
code.hljs {
color: #cdd6f4;
background: transparent;
diff --git a/lib/alchemy_pub/engine.ex b/lib/alchemy_pub/engine.ex
index 816e3f6..387ba3d 100644
--- a/lib/alchemy_pub/engine.ex
+++ b/lib/alchemy_pub/engine.ex
@@ -32,7 +32,7 @@ defmodule AlchemyPub.Engine do
nil
end
- defp compile(md) do
+ defp compile(md, is_deck) do
link_headers = fn {h, attrs, content, meta} ->
id = urlify(content)
@@ -51,6 +51,10 @@ defmodule AlchemyPub.Engine do
], meta}}
end
+ page_split = fn {hr, _attrs, content, meta} ->
+ {:replace, {hr, [{"class", "split"}], content, meta}}
+ end
+
ast =
Earmark.as_ast!(md,
pure_links: false,
@@ -60,17 +64,31 @@ defmodule AlchemyPub.Engine do
title = find_h1(ast)
+ processors =
+ if is_deck do
+ [{"hr", page_split}]
+ else
+ [{"h2", link_headers}, {"h3", link_headers}]
+ end
+
postprocessor =
Earmark.Transform.make_postprocessor(
- Earmark.Options.make_options!(
- registered_processors: [{"h2", link_headers}, {"h3", link_headers}]
- )
+ Earmark.Options.make_options!(registered_processors: processors)
)
- {title,
- ast
- |> Earmark.Transform.map_ast(postprocessor)
- |> Earmark.transform()}
+ content =
+ ast
+ |> Earmark.Transform.map_ast(postprocessor)
+ |> Earmark.transform()
+
+ content =
+ if is_deck do
+ content |> String.split("
")
+ else
+ content
+ end
+
+ {title, content}
end
def title(filename, h1, frontmatter) do
@@ -132,7 +150,7 @@ defmodule AlchemyPub.Engine do
Date.new!(y, m, d)
end
- {h1, content} = compile(md)
+ {h1, content} = compile(md, is_deck)
filename = path |> Path.basename() |> Path.rootname()
title = title(filename, h1, frontmatter)
diff --git a/lib/alchemy_pub_web/page_live.ex b/lib/alchemy_pub_web/page_live.ex
index 64a9d2b..bab4f8e 100644
--- a/lib/alchemy_pub_web/page_live.ex
+++ b/lib/alchemy_pub_web/page_live.ex
@@ -94,6 +94,17 @@ defmodule AlchemyPubWeb.PageLive do
socket =
case page do
+ {title, :deck, _date, meta, content} ->
+ socket
+ |> assign(
+ page_title: meta |> Map.get("title"),
+ meta: meta,
+ content: paginate(content, params["p"]),
+ title: title,
+ tag: nil,
+ track_valid: true
+ )
+
{title, _rank, _date, meta, content} ->
socket
|> assign(
@@ -167,6 +178,11 @@ defmodule AlchemyPubWeb.PageLive do
end)
end
+ defp paginate(content, page) do
+ {page, _} = Integer.parse(page || 0)
+ content |> Enum.at(page)
+ end
+
defp build_content(tag, title, all) do
(tag &&
"Tag: #{title}
" <>
diff --git a/lib/alchemy_pub_web/page_live.html.heex b/lib/alchemy_pub_web/page_live.html.heex
index 2d6edc7..fce15b7 100644
--- a/lib/alchemy_pub_web/page_live.html.heex
+++ b/lib/alchemy_pub_web/page_live.html.heex
@@ -99,14 +99,14 @@
@@ -130,7 +130,16 @@
published {@meta["date"]}
-
+
+ {raw(@content)}
+
+
{raw(@content)}
diff --git a/mix.exs b/mix.exs
index 0e984f1..6361049 100644
--- a/mix.exs
+++ b/mix.exs
@@ -4,7 +4,7 @@ defmodule AlchemyPub.MixProject do
def project do
[
app: :alchemy_pub,
- version: "0.2.0",
+ version: "0.3.0",
elixir: "~> 1.18",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,
diff --git a/priv/pages/Deck.md b/priv/pages/Deck.md
index f3b611f..62c5061 100644
--- a/priv/pages/Deck.md
+++ b/priv/pages/Deck.md
@@ -4,8 +4,58 @@ title: LiveDeck
tags: Speaking
---
-Introduction
+# LiveDeck
---
-Second page
+## Code blocks
+
+This is how you do a code block:
+
+```elixir
+{
+ title,
+ ast
+ |> Earmark.Transform.map_ast(postprocessor)
+ |> Earmark.transform()
+}
+```
+
+---
+
+### Styling text
+
+> a block quote.
+
+*emphasized text*
+
+**strong emphasis**
+
+~~strikethrough~~
+
+---
+
+### Images
+
+
+
+---
+
+#### Lists
+
+1. This is a list item.
+
+ > containing a block quote
+
+* List
+ * sublist
+ * test
+
+---
+
+## Tables
+
+| a | b |
+| --- | :---: |
+| 1 | 2 |
+| 3 | 4 |