Add breadcrumbs to views: page, article (#14)

This commit is contained in:
Anders Englöf Ytterström 2024-10-03 10:00:57 +02:00 committed by GitHub
parent ebff42d899
commit fae04e3fd7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 54 additions and 19 deletions

View file

@ -50,12 +50,18 @@ defmodule Mse25Web.ItemController do
"pubDate" => published_at, "pubDate" => published_at,
"date_updated" => updated_at "date_updated" => updated_at
}) do }) do
updated =
case updated_at do
nil -> published_at
s -> String.slice(s, 0..9)
end
[ [
heading: heading, heading: heading,
contents: Earmark.as_html!(contents), contents: Earmark.as_html!(contents),
published_at: published_at, published_at: published_at,
updated_at: updated_at, updated_at: updated,
year: 2024 year: String.slice(published_at, 0..3)
] ]
end end
@ -98,7 +104,7 @@ defmodule Mse25Web.ItemController do
[ [
heading: heading, heading: heading,
contents: Earmark.as_html!(contents), contents: Earmark.as_html!(contents),
updated_at: updated_at updated_at: String.slice(updated_at, 0..9)
] ]
end end
end end

View file

@ -1,12 +1,33 @@
<article> <article class="article">
<header> <header>
<date><%= @published_at %></date> <ol class="breadcrumbs" itemscope itemtype="https://schema.org/BreadcrumbList">
<h1><%= @heading %></h1> <li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
</header> <a href="/" rel="home">
<span itemprop="name">madr.se</span>
</a>
<meta itemprop="position" content="1" />
</li>
<li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
<a href="/webblogg">
<span itemprop="name">Webblogg</span>
</a>
<meta itemprop="position" content="2" />
</li>
<li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
<a href={"/" <> @year}>
<span itemprop="name"><%= @year %></span>
</a>
<meta itemprop="position" content="3" />
</li>
</ol>
<h1><%= @heading %></h1>
</header>
<%= raw @contents %> <%= raw(@contents) %>
<footer> <footer>
<p>Skribent: Anders Englöf Ytterström. Publicerad <%= @published_at %> och senast uppdaterad <%= @updated_at %>.</p> <p>
</footer> Publicerad <%= @published_at %> <br />och senast uppdaterad <%= @updated_at %>
</p>
</footer>
</article> </article>

View file

@ -1,11 +1,19 @@
<article> <article>
<header> <header>
<h1><%= @heading %></h1> <ol class="breadcrumbs" itemscope itemtype="https://schema.org/BreadcrumbList">
</header> <li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
<a href="/" rel="home">
<span itemprop="name">madr.se</span>
</a>
<meta itemprop="position" content="1" />
</li>
</ol>
<h1><%= @heading %></h1>
</header>
<%= raw @contents %> <%= raw(@contents) %>
<footer> <footer>
<p>Skribent: Anders Englöf Ytterström. Senast uppdaterad <%= @updated_at %>.</p> <p>Senast uppdaterad <%= @updated_at %></p>
</footer> </footer>
</article> </article>