Skip to content

Commit

Permalink
Add pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
chesterhow committed Mar 12, 2017
1 parent a0208bb commit e899f33
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 5 deletions.
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ title: Tale
subtitle: by Chester
paginate: 1
baseurl: ""
url: ""
url: "https://chesterhow.github.io/tale/"

# Assets
sass:
Expand Down
2 changes: 1 addition & 1 deletion _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<a href="{{ site.baseurl }}/" title="Home">
<h2>{{ site.title }}</h2>
</a>
<h4>{{ site.subtitle }}</h4>
<h4>[ {{ site.subtitle }} ]</h4>
</header>

<main>
Expand Down
16 changes: 16 additions & 0 deletions _posts/2017-03-08-welcome-to-jekyll.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
layout: post
title: "Introducing Tale 3"
date: 2017-03-08 12:32:48 +0800
categories: jekyll update
synopsys: "Tale is a minimal Jekyll theme for writers. Find out more here."
---
You’ll find this post in your `_posts` directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run `jekyll serve`, which launches a web server and auto-regenerates your site when a file is updated.

To add new posts, simply add a file in the `_posts` directory that follows the convention `YYYY-MM-DD-name-of-post.ext` and includes the necessary front matter. Take a look at the source for this post to get an idea about how it works.

Check out the [Jekyll docs][jekyll-docs] for more info on how to get the most out of Jekyll. File all bugs/feature requests at [Jekyll’s GitHub repo][jekyll-gh]. If you have questions, you can ask them on [Jekyll Talk][jekyll-talk].

[jekyll-docs]: https://jekyllrb.com/docs/home
[jekyll-gh]: https://github.com/jekyll/jekyll
[jekyll-talk]: https://talk.jekyllrb.com/
2 changes: 1 addition & 1 deletion _posts/2017-03-09-welcome-to-jekyll.markdown
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
layout: post
title: "Introducing Tale"
title: "Introducing Tale 2"
date: 2017-03-09 12:32:48 +0800
categories: jekyll update
synopsys: "Tale is a minimal Jekyll theme for writers. Find out more here."
Expand Down
32 changes: 32 additions & 0 deletions _sass/_home.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,35 @@
text-decoration: none;
}
}

.pagination {
font-family: $serif-font;
margin-bottom: 20px;
position: relative;
text-align: center;

span {
color: $default-shade;
font-size: 1.3em;
}

a {
@include transition(all .3s ease-out);
color: $default-color;
font-size: 1.3em;
position: absolute;
text-decoration: none;

&:hover {
color: $default-tint;
}
}

.left {
left: 0;
}

.right {
right: 0;
}
}
14 changes: 12 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,26 @@
title: Home
---

{% for post in site.posts %}
{% for post in paginator.posts %}
<div class="post-preview">
<time datetime="{{ post.date }}">{{ post.date | date_to_string }}</time>
<h1>{{ post.title }}</h1>

<p>{{ post.content | truncatewords: 70 | strip_html }}</p>


<div class="post-link">
<a href="{{ post.url }}">continue reading</a>
</div>
</div>
{% endfor %}

<div class="pagination">
{% if paginator.previous_page %}
<a href="{{ paginator.previous_page_path | prepend: site.url }}" class="left">&#8592;</a>
{% endif %}
{% if paginator.next_page %}
<a href="{{ paginator.next_page_path | prepend: site.url }}" class="right">&#8594;</a>
{% endif %}

<span>{{ paginator.page }}</span>
</div>

0 comments on commit e899f33

Please sign in to comment.