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
|
posts -> posts
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def format_date(date) do
|
||||||
|
Calendar.strftime(date, "%Y-%m-%d")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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>
|
||||||
|
|
Loading…
Reference in a new issue