Skip to content

Commit

Permalink
blog layout with pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
Paula Mendez committed Aug 19, 2022
1 parent 0ec0382 commit 8200985
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions _layouts/blog_ly.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
layout: default
---
<!-- Just some nice to have styles for the pager buttons -->
<style>
ul.pager { text-align: center; list-style: none; }
ul.pager li {display: inline;border: 1px solid black; padding: 10px; margin: 5px;}
</style>

<div class="blog">

<h1 class="page-heading">Blog Posts</h1>

{{ content }}

<ul class="post-list">
<!--
Here is the main paginator logic called.
All calls to site.posts should be replaced by paginator.posts
-->
{% for post in paginator.posts %}
<li>
<span class="post-meta">{{ post.date | date: "%b %-d, %Y" }}</span>

<h2>
<a class="post-link" href="{{ post.url | relative_url }}">{{ post.title | escape }}</a>
</h2>
</li>
{% endfor %}
</ul>

<!--
Showing buttons to move to the next and to the previous list of posts (pager buttons).
-->
{% if paginator.total_pages > 1 %}
<ul class="pager">
{% if paginator.previous_page %}
<li class="previous">
<a href="{{ paginator.previous_page_path | prepend: site.baseurl | replace: '//', '/' }}">&larr; Newer Posts</a>
</li>
{% endif %}
{% if paginator.next_page %}
<li class="next">
<a href="{{ paginator.next_page_path | prepend: site.baseurl | replace: '//', '/' }}">Older Posts &rarr;</a>
</li>
{% endif %}
</ul>
{% endif %}


</div>

0 comments on commit 8200985

Please sign in to comment.