GitXplorerGitXplorer
t

infinite-jekyll

public
228 stars
36 forks
11 issues

Commits

List of commits on branch master.
Unverified
cb72fc373f2dda79ef0f087dd21b57a673507f8f

Merge pull request #17 from brodyw/master

ttobiasahlin committed 10 years ago
Unverified
f9f3d9f1a55d2fec7d516b7bfff18fda8331366e

Replaced instances of "posts" with updated "post-list"

bbwest25 committed 10 years ago
Unverified
83dd2158d2f9da3c6aeec218ae80807d88b9e795

Merge pull request #4 from tobiasahlin/syntax-highlighting-for-readme

ttobiasahlin committed 11 years ago
Unverified
8e12a3313c90b7a756540aa538c5803c4a3a7644

HTML syntax

ttobiasahlin committed 11 years ago
Unverified
7b7aeecee68ba83464cfae5514f23717a35bdddb

Merge pull request #2 from tobiasahlin/update-spinner

ttobiasahlin committed 11 years ago
Unverified
694b88b5c4ac45848ef85a4c9cd9d7bb993305d3

Update to latest pulse spinner from SpinKit

ttobiasahlin committed 11 years ago

README

The README file for this repository.

Infinite Jekyll

Infinite scroll for Jekyll based blogs. See it in action at tobiasahlin.com/blog/.

Getting Started

Add the js folder and all-posts.json to the root of your Jekyll site. If you're not already using jQuery, open _layouts/default.html and include it:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

In _layouts/default.html, include infinite-jekyll.js after jQuery:

<script src="/js/infinite-jekyll.js"></script>

Render posts, not links

How fun is it to only see links? Open up index.html. Find this line:

<li><span>{{ post.date | date_to_string }}</span> &raquo; <a href="{{ post.url }}">{{ post.title }}</a></li>

Remove everything within the li. Open up _layouts/post.html and copy the markup for single posts. Paste it within the li, and replace every instance of page. with post.. This is how it should look using the default markup:

<li>
	<h2>{{ post.title }}</h2>
	<p class="meta">{{ post.date | date_to_string }}</p>

	<div class="post">
	{{ post.content }}
	</div>
</li>

Limit the number of posts

Per default, Jekyll will render all posts in your entire archive. For lazy loading to make sense, we need to set a limit. Open up index.html and find this line:

{% for post in site.posts %}

Change it to:

{% for post in site.posts limit: 10 %}	

You can change 10 to whatever number you like. The same number will be used for lazy loading new posts, so 10 will render 10 static post, and then fetch another 10 posts every time you get near the bottom of the page.

Add the spinner

You should see your 10 latest posts on the front page, but no infinite scroll yet. Infinite Jekyll will only try to lazy load posts if there's a spinner present. At the very end of index.html, add the spinner:

<div class="infinite-spinner"></div>

spinner.css contains a simple CSS spinner that works in most modern browsers. Open up css/main.css, and at the very end, paste everything from spinner.css.

And you're done. Happy scrolling!