Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added pagination to homepage #20

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Daktilo is a [Jekyll](jekyllrb.com) theme with a minimal design inspired from ty
# How to use it
Start by cloning the repository, then check the `_config.yml` file and change it accordingly.
Note that the `title` property is what will be displayed as logo.
Change the `num` in `paginate:num` to see the number of posts on one page.

Finally execute `jekyll serve --watch` and head to [localhost:4000](http://127.0.0.1:4000) to see the result.

Expand Down
7 changes: 6 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Site settings
gems: [jekyll-paginate]

# Site settings
title: Daktilo
description: >
Write an awesome description for your new site here. You can edit this
Expand Down Expand Up @@ -27,3 +29,6 @@ exclude: ["README.md", "README.html"]
# Build settings
highlighter: null
markdown: kramdown

paginate: 5
paginate_path: "/page:num"
10 changes: 9 additions & 1 deletion _sass/_default.scss
Original file line number Diff line number Diff line change
Expand Up @@ -302,4 +302,12 @@ strong {
.post-title__subtitle {
font-size: 18px;
}
}
}

.pagination {
font-size: 14px;
padding: 0px;
text-align: center;
position: relative;

}
20 changes: 18 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,28 @@
---

<ul class="list-posts">
{% for post in site.posts %}
{% for post in paginator.posts %}
<li class="post-teaser">
<a href="{{ post.url | prepend: site.baseurl }}">
<span class="post-teaser__title">{{ post.title }}</span>
<span class="post-teaser__date">{{ post.date | date: "%d %B %Y" }}</span>
</a>
</li>
{% endfor %}
{% endfor %}

<!-- Pagination links -->
<div class="pagination">
{% if paginator.previous_page %}
<a href="{{ paginator.previous_page_path }}" class="previous">Previous</a>
{% else %}
<span class="previous">Previous</span>
{% endif %}
<span class="page_number ">Page: {{ paginator.page }} of {{ paginator.total_pages }}</span>
{% if paginator.next_page %}
<a href="{{ paginator.next_page_path }}" class="next">Next</a>
{% else %}
<span class="next ">Next</span>
{% endif %}
</div>

</ul>