burguillos.info/templates/page/_list_posts.html.ep

35 lines
1.2 KiB
Plaintext
Raw Normal View History

2023-05-03 05:32:55 +02:00
% my $posts = stash 'posts';
<h2>Artículos</h2>
<div class="articles">
% unless (defined $posts && @$posts) {
<p>Parece que aun no hay artículos.</p>
% }
% for my $post (@$posts) {
<a href="/posts/<%=$post->{slug}%>">
<article><%
my $date_article = DateTime::Format::ISO8601->parse_datetime($post->{date});
$date_article->set_time_zone('Europe/Madrid');
2023-05-07 05:15:22 +02:00
%><div class="article-up-part">
<p class="date"><%= ''.$date_article %></p><%
2023-11-09 17:38:17 +01:00
my $title = $post->{title};
if (length($title) > 50) {
$title = substr($title, 0, 47).'...';
}
2023-05-03 05:32:55 +02:00
if (defined $post->{image}) {
2023-05-07 05:15:22 +02:00
%><div class="image-container">
2023-11-09 17:38:17 +01:00
<img alt="Portada de <%=$title%>" src="<%=$post->{image}%>"/>
2023-05-07 05:15:22 +02:00
</div><%
}
2023-05-07 16:46:51 +02:00
%></div><div class="article-down-part"><div>
2023-11-09 17:38:17 +01:00
<h3><%=$title%></h3><%
2023-05-03 05:32:55 +02:00
my $xml = Mojo::DOM->new($post->{content});
my $text = $xml->all_text;
2023-11-09 17:38:17 +01:00
if (length($text) > 50) {
$text = substr($text, 0, 47).'...';
2023-05-03 05:32:55 +02:00
}
2023-05-07 05:15:22 +02:00
%><p><%=$text%></p><p class="author">Escrito por <%=$post->{author}%></p>
2023-05-07 16:46:51 +02:00
</div></div></article>
2023-05-03 05:32:55 +02:00
</a>
% }
</div>