29 lines
1.5 KiB
Twig
29 lines
1.5 KiB
Twig
{% extends 'base.html.twig' %}
|
|
|
|
{% block title %}Home - Posts{% endblock %}
|
|
|
|
{% block body %}
|
|
<h1 class="text-center">Last 5 posts</h1>
|
|
<div class="container-fluid justify-content-center">
|
|
{% for post in posts %}
|
|
<div class="card text-center">
|
|
<div class="card-body">
|
|
<h5 class="card-title">{{ post.title }}</h5>
|
|
<p class="card-text">{{ post.description }}</p>
|
|
<a href="{{ path('post', {slug: post.slug}) }}" class="btn btn-primary">Read more</a>
|
|
</div>
|
|
<div class="card-footer text-muted">{{ post.publishedAt.format('Y-m-d H:i:s') }}</div>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
<nav aria-label="Post navigation">
|
|
<ul class="pagination justify-content-center">
|
|
<li class="page-item {{ page <= 0 ? "disabled" : "" }}"><a class="page-link" href="{{ path('home', {'page': page-1}) }}">Previous</a></li>
|
|
{% for p in 0..pages+1 %}
|
|
{% set active = p == page %}
|
|
<li class="page-item {{ active ? 'active' : '' }} {{ active ? '' : 'aria-current="page"' }}"><a class="page-link" href="{{ path('home', {'page': p}) }}">{{ p }} {{ active ? '<span class="visually-hidden">(current)</span>' : '' }}</a></li>
|
|
{% endfor %}
|
|
<li class="page-item {{ page > pages ? "disabled" : "" }}"><a class="page-link" href="{{ path('home', {'page': page+1}) }}">Next</a></li>
|
|
</ul>
|
|
</nav>
|
|
{% endblock %}
|