Commit 6c4002e3 authored by Jacek Lebioda's avatar Jacek Lebioda
Browse files

Pagination

parent 6ba58231
......@@ -3,3 +3,8 @@
source "https://rubygems.org"
gemspec
group :jekyll_plugins do
gem "jekyll-paginate-v2", "~> 1.7"
gem "jekyll-feed", "~> 0.6"
end
......@@ -67,6 +67,29 @@ Don't forget to save and commit the file.
Create a folder in `assets/banners` directory, with `banner.svg`, `logos.svg` and `motto.svg` files (for reference, consult `assets/banners/frozen` directory. Do not exceed image dimensions). Update `_config.yml` file with the name of directory you created for the images.
In case `logos.svg` file is wide, change `logo: small` to `logo: big` in `_config.yml`.
### Enabling and configuring pagination
The template includes `jekyll-paginate-v2` plugin by default.
To use it, configure the pagination following instructions from the next paragraph, specify `paginated_index` as the post layout for the index page (it will contain the paginator), create a directory called `_posts` in the project root directory and fill it with posts.
There are two sections in `_config.yml`, that refer to pagination: first, ` - jekyll-paginate-v2` line in plugins section, and then the configuration dictionary:
```
pagination:
enabled: true # Change to false to disable pagination
title: ':title - page :num of :max' # Customize the text
per_page: 8 # How many posts should be displayed on one page
permalink: '/page/:num/' # The URL to the index of pagination
limit: 0
sort_field: 'date' # How the posts should be sorted. can also be: `title` or any page attribute
sort_reverse: true
trail: # How many pages should be shown in paginator.
before: 2 # Show 2 before the current one, e.g. `< 5 6 CURRENT ...`
after: 2 # Show 2 after the current one, e.g. `... CURRENT 6 7 >`
```
To disable it completely, set `enabled` to `false`, remove the aforementioned sections from the configuration, and `gem "jekyll-paginate-v2", "~> 1.7"` from `Gemfile` (from the project root).
Refer to its [documentation](https://github.com/sverrirs/jekyll-paginate-v2/blob/master/README-GENERATOR.md) for more detailed instructions.
### Enabling Google Analytics
To enable Google Anaytics, add the following lines to your Jekyll site:
......
......@@ -30,6 +30,21 @@ linkedin_schoolname: university-of-luxembourg
markdown: kramdown
plugins:
- jekyll-seo-tag
- jekyll-feed
- jekyll-paginate-v2
# Pagination Settings
pagination:
enabled: true
title: ':title - page :num of :max'
per_page: 8
permalink: '/page/:num/'
limit: 0
sort_field: 'date'
sort_reverse: true
trail:
before: 2
after: 2
# Exclude from processing.
# The following items will not be processed, by default. Create a custom list
......
---
layout: default
---
<style>
h2 {margin-bottom: 3px;}
ul.pager { text-align: center; list-style: none; }
ul.pager li {display: inline;border: 1px solid black; padding: 10px; margin: 5px;}
</style>
<div class="home">
<h1 class="page-heading">
Posts
</h1>
{{ content }}
<ul class="post-list">
{% comment %}
Here is the main paginator logic called.
All calls to site.posts should be replaced by paginator.posts
{% end comment %}
{% 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>
<span class="post-meta">{% if post.synopsis %}{{ post.synopsis }}{% endif %}</span>
</li>
{% endfor %}
</ul>
{% comment %}
Showing buttons to move to the next and to the previous list of posts (pager buttons).
Some legacy code (might be useful):
{% 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 %}
{% end comment %}
{% if paginator.page_trail %}
<ul class="pager" style="margin-top: 60px;">
{% if paginator.previous_page %}
<a href="{{ paginator.previous_page_path | prepend: site.baseurl | replace: '//', '/' }}">
<li class="previous">&laquo;</li>
</a>
{% endif %}
{% for trail in paginator.page_trail %}
<a href="{{ trail.path | prepend: site.baseurl }}" title="{{trail.title}}">
<li {% if page.url == trail.path %}class="pager-active"{% endif %}>{{ trail.num | replace: " ", "" }}</li>
</a>
{% endfor %}
{% if paginator.next_page %}
<a href="{{ paginator.next_page_path | prepend: site.baseurl | replace: '//', '/' }}">
<li class="next">&raquo;</li>
</a>
{% endif %}
</ul>
{% endif %}
<p class="rss-subscribe" style="float: right; font-size: smaller;">subscribe <a href="{{ "/feed.xml" | relative_url }}">via RSS</a></p>
</div>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment