diff --git a/assets/css/app.css b/assets/css/app.css index b07c5c9..2ba3d84 100644 --- a/assets/css/app.css +++ b/assets/css/app.css @@ -47,8 +47,8 @@ @apply flex md:flex-row lg:flex-col mb-6 lg:mb-0; } - & .menu { - @apply flex-1; + & ul.menu { + @apply m-0; } } diff --git a/lib/chiya/notes/note.ex b/lib/chiya/notes/note.ex index 9db2e01..04d18d4 100644 --- a/lib/chiya/notes/note.ex +++ b/lib/chiya/notes/note.ex @@ -102,6 +102,16 @@ defmodule Chiya.Notes.Note do end end + def note_excerpt(note_content) do + if String.contains?(note_content, "") do + note_content + |> String.split("") + |> List.first() + else + String.slice(note_content, 0..150) <> ".." + end + end + @doc false def changeset(note, attrs) do # if you need to have a preloaded note here, diff --git a/lib/chiya_web/components/layouts/root_public.html.heex b/lib/chiya_web/components/layouts/root_public.html.heex index 976968b..6344eeb 100644 --- a/lib/chiya_web/components/layouts/root_public.html.heex +++ b/lib/chiya_web/components/layouts/root_public.html.heex @@ -72,30 +72,24 @@
diff --git a/lib/chiya_web/controllers/page_html/note_list_default.html.heex b/lib/chiya_web/controllers/page_html/note_list_default.html.heex index 9885f4e..ee90a3d 100644 --- a/lib/chiya_web/controllers/page_html/note_list_default.html.heex +++ b/lib/chiya_web/controllers/page_html/note_list_default.html.heex @@ -1,28 +1,30 @@
<%= for note <- assigns.notes do %> -
- -
- +
- <%= if assigns.show_content do %> -

- <%= String.slice(note.content, 0..150) %> -

- <% end %> + <%= if assigns.show_content do %> +

+ <%= Chiya.Notes.Note.note_excerpt(note.content) %> +

+ <% end %> +
<% end %>