add mono css framework, add some boiler plate, get started on responsive design fixes
This commit is contained in:
44
lib/layouts/index_layout.ex
Normal file
44
lib/layouts/index_layout.ex
Normal file
@@ -0,0 +1,44 @@
|
||||
defmodule Llmex.IndexLayout do
|
||||
use Tableau.Layout, layout: Llmex.RootLayout
|
||||
use Phoenix.Component
|
||||
|
||||
def template(assigns) do
|
||||
~H"""
|
||||
<h1><%= @page[:title] || "Latest Posts" %></h1>
|
||||
|
||||
<%= if @page[:description] do %>
|
||||
<p><%= @page[:description] %></p>
|
||||
<% end %>
|
||||
|
||||
<%= if assigns[:posts] && length(@posts) > 0 do %>
|
||||
<ul>
|
||||
<%= for post <- @posts do %>
|
||||
<li>
|
||||
<h2><a href={post.permalink}><%= post.title %></a></h2>
|
||||
<%= if post[:date] do %>
|
||||
<time datetime={post[:date]}><%= format_date(post[:date]) %></time>
|
||||
<% end %>
|
||||
<%= if post[:description] do %>
|
||||
<p><%= post[:description] %></p>
|
||||
<% end %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% else %>
|
||||
<p>No posts found.</p>
|
||||
<% end %>
|
||||
|
||||
<%= {:safe, render(@inner_content)} %>
|
||||
"""
|
||||
end
|
||||
|
||||
defp format_date(date_string) when is_binary(date_string) do
|
||||
case Date.from_iso8601(date_string) do
|
||||
{:ok, date} -> Calendar.strftime(date, "%B %d, %Y")
|
||||
{:error, _} -> date_string
|
||||
end
|
||||
end
|
||||
|
||||
defp format_date(%Date{} = date), do: Calendar.strftime(date, "%B %d, %Y")
|
||||
defp format_date(_), do: ""
|
||||
end
|
10
lib/layouts/page_layout.ex
Normal file
10
lib/layouts/page_layout.ex
Normal file
@@ -0,0 +1,10 @@
|
||||
defmodule Llmex.PageLayout do
|
||||
use Tableau.Layout, layout: Llmex.RootLayout
|
||||
use Phoenix.Component
|
||||
|
||||
def template(assigns) do
|
||||
~H"""
|
||||
<%= {:safe, render(@inner_content)} %>
|
||||
"""
|
||||
end
|
||||
end
|
@@ -5,6 +5,19 @@ defmodule Llmex.PostLayout do
|
||||
def template(assigns) do
|
||||
~H"""
|
||||
<%= {:safe, render(@inner_content)} %>
|
||||
<%= if @page[:date] do %>
|
||||
<time datetime={@page[:date]}><%= format_date(@page[:date]) %></time>
|
||||
<% end %>
|
||||
"""
|
||||
end
|
||||
|
||||
defp format_date(date_string) when is_binary(date_string) do
|
||||
case Date.from_iso8601(date_string) do
|
||||
{:ok, date} -> Calendar.strftime(date, "%B %d, %Y")
|
||||
{:error, _} -> date_string
|
||||
end
|
||||
end
|
||||
|
||||
defp format_date(%Date{} = date), do: Calendar.strftime(date, "%B %d, %Y")
|
||||
defp format_date(_), do: ""
|
||||
end
|
||||
|
@@ -13,18 +13,35 @@ defmodule Llmex.RootLayout do
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
|
||||
<title>
|
||||
<%= [@page[:title], Llmex]
|
||||
<%= [@page[:title], "Llmex Blog"]
|
||||
|> Enum.filter(& &1)
|
||||
|> Enum.intersperse("|")
|
||||
|> Enum.join(" ") %>
|
||||
</title>
|
||||
|
||||
<link rel="stylesheet" href="/css/simple.css" />
|
||||
<link rel="stylesheet" href="/css/mono.css" />
|
||||
<link rel="stylesheet" href="/css/responsive.css" />
|
||||
<meta name="description" content={@page[:description] || "A simple blog built with Elixir and Tableau"} />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<body class="mono-all">
|
||||
<aside>
|
||||
<nav>
|
||||
<h1><a href="/">Llmex Blog</a></h1>
|
||||
<ul>
|
||||
<li><a href="/">Home</a></li>
|
||||
<li><a href="/posts">Posts</a></li>
|
||||
<li><a href="/about">About</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
</aside>
|
||||
|
||||
<main>
|
||||
<%= render @inner_content %>
|
||||
|
||||
<footer>
|
||||
<p>© <%= Date.utc_today().year %> Llmex Blog. Built with <a href="https://github.com/artalar/mono" target="_blank">Mono</a> and <a href="https://github.com/elixir-tools/tableau" target="_blank">Tableau</a></p>
|
||||
</footer>
|
||||
</main>
|
||||
</body>
|
||||
|
||||
|
Reference in New Issue
Block a user