Add recent posts and date formatting.

This commit is contained in:
Jessica Canady 2024-08-25 12:56:26 -04:00
parent b829cabaf0
commit a7de9ac1a5
Signed by: phoenix
SSH key fingerprint: SHA256:aaLOzOrLi+0n4eDZNQKH97PehwRt6KSE5fYJc+ZRKCQ
4 changed files with 419 additions and 402 deletions

File diff suppressed because it is too large Load diff

View file

@ -44,4 +44,8 @@ defmodule JOL.Blog do
posts -> posts posts -> posts
end end
end end
def format_date(date) do
Calendar.strftime(date, "%Y-%m-%d")
end
end end

View file

@ -4,8 +4,7 @@ defmodule JOLWeb.PageController do
@spec home(Plug.Conn.t(), any()) :: Plug.Conn.t() @spec home(Plug.Conn.t(), any()) :: Plug.Conn.t()
def home(conn, _params) do def home(conn, _params) do
conn conn
|> assign(:page_title, "Home") |> render(:home, page_title: "Welcome!", posts: JOL.Blog.recent_posts())
|> render(:home)
end end
def about(conn, _params) do def about(conn, _params) do

View file

@ -8,6 +8,16 @@
<p>I write here about those things, about general tech dorkery, and about my experience with being <strong>super</strong> trans and learning who I am.</p> <p>I write here about those things, about general tech dorkery, and about my experience with being <strong>super</strong> trans and learning who I am.</p>
</div> </div>
<div> <div>
<h2>Recent Posts</h2>
<ul class="recent-posts">
<%= for post <- @posts do %>
<li>
<date><%= JOL.Blog.format_date(post.date) %></date>
<.link href={~p"/blog/#{post.slug}"}><%= post.title %> </.link>
</li>
<% end %>
</ul>
</div> </div>
</div> </div>