Add recent posts and date formatting.
This commit is contained in:
parent
b829cabaf0
commit
a7de9ac1a5
File diff suppressed because it is too large
Load diff
|
@ -44,4 +44,8 @@ defmodule JOL.Blog do
|
|||
posts -> posts
|
||||
end
|
||||
end
|
||||
|
||||
def format_date(date) do
|
||||
Calendar.strftime(date, "%Y-%m-%d")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,8 +4,7 @@ defmodule JOLWeb.PageController do
|
|||
@spec home(Plug.Conn.t(), any()) :: Plug.Conn.t()
|
||||
def home(conn, _params) do
|
||||
conn
|
||||
|> assign(:page_title, "Home")
|
||||
|> render(:home)
|
||||
|> render(:home, page_title: "Welcome!", posts: JOL.Blog.recent_posts())
|
||||
end
|
||||
|
||||
def about(conn, _params) do
|
||||
|
|
|
@ -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>
|
||||
</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>
|
||||
|
|
Loading…
Reference in a new issue