diff --git a/assets/css/app.css b/assets/css/app.css
index cbb2412..3687625 100644
--- a/assets/css/app.css
+++ b/assets/css/app.css
@@ -89,6 +89,26 @@
.prose em {
@apply text-theme-quaternary;
}
+
+ .prose h1, h2, h3, h4 {
+ @apply before:font-light before:text-theme-base/25;
+ }
+
+ .prose h1 {
+ @apply before:content-['#'];
+ }
+
+ .prose h2 {
+ @apply before:content-['##'];
+ }
+
+ .prose h3 {
+ @apply before:content-['###'];
+ }
+
+ .prose h4 {
+ @apply before:content-['####'];
+ }
}
@layer components {
diff --git a/lib/chiya_web/controllers/page_html.ex b/lib/chiya_web/controllers/page_html.ex
index daf0c91..1a11113 100644
--- a/lib/chiya_web/controllers/page_html.ex
+++ b/lib/chiya_web/controllers/page_html.ex
@@ -1,8 +1,23 @@
defmodule ChiyaWeb.PageHTML do
use ChiyaWeb, :html_public
+ import Phoenix.HTML.Tag, only: [content_tag: 3, content_tag: 2]
embed_templates "page_html/*"
def tag_list([]), do: "No Tags"
def tag_list(tags), do: Enum.map_join(tags, ", ", fn t -> t.name end)
+
+ def render_outline(note) do
+ list = ChiyaWeb.Outline.get(note.content)
+ Enum.map(list, &do_render_outline/1)
+ end
+
+ def do_render_outline(%{text: text, children: children, level: _level}) do
+ content_tag(:ul, [class: "m-0"],
+ do: [
+ content_tag(:li, do: content_tag(:a, text, href: "##{Slugger.slugify(text)}")),
+ Enum.map(children, &do_render_outline/1)
+ ]
+ )
+ end
end
diff --git a/lib/chiya_web/controllers/page_html/note.html.heex b/lib/chiya_web/controllers/page_html/note.html.heex
index 3a5c413..1e75752 100644
--- a/lib/chiya_web/controllers/page_html/note.html.heex
+++ b/lib/chiya_web/controllers/page_html/note.html.heex
@@ -3,6 +3,10 @@
<%= @note.name %>
+
+
<%= Markdown.render(@note.content) |> raw %>