Skip to content

Commit

Permalink
Add Pagination to Articles
Browse files Browse the repository at this point in the history
  • Loading branch information
yousinix committed Jun 26, 2019
1 parent dfacef9 commit b556230
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
4 changes: 4 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ author:
# vimeo : your_username
# youtube : your_channel_name

# Pagination
paginate: 6
paginate_path: "/articles/page-:num/"

# Collections
collections:
projects:
Expand Down
21 changes: 20 additions & 1 deletion _includes/articles.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="card-group mt-2">

{% for post in site.posts %}
{% for post in paginator.posts %}

{% comment %} Default Styles {% endcomment %}
{% assign card_style = '' %}
Expand Down Expand Up @@ -54,4 +54,23 @@ <h3 class="card-title">{{ post.title }}</h3>

{% endfor %}

<!-- Pagination links -->
<div class="mx-auto my-3">

{% if paginator.previous_page %}
<a href="{{ paginator.previous_page_path | relative_url }}" class="badge badge-primary"><</a>
{% else %}
<span class="badge badge-light text-muted"><</span>
{% endif %}

<small class="mx-2"> Page <b>{{ paginator.page }}</b> of {{ paginator.total_pages }} </small>

{% if paginator.next_page %}
<a href="{{ paginator.next_page_path | relative_url }}" class="badge badge-primary">></a>
{% else %}
<span class="badge badge-light text-muted">></span>
{% endif %}

</div>

</div>
2 changes: 2 additions & 0 deletions _includes/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
{% assign pages = site.html_pages | sort: 'weight' %}
{% for site_page in pages %}
{% if site_page.title %}
{% unless site_page.url contains 'page' %}
<a class="nav-item nav-link {% if page.url contains site_page.url %} active {% endif %}" href="{% if site_page.external_url %} {{ site_page.external_url }} {% else %} {{ site_page.url | relative_url }} {% endif %}">{{ site_page.title }}</a>
{% endunless %}
{% endif %}
{% endfor %}
</div>
Expand Down
1 change: 0 additions & 1 deletion pages/articles.html → articles/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
layout: default
title: Articles
permalink: /articles/
weight: 2
---

Expand Down

0 comments on commit b556230

Please sign in to comment.