Instantly share code, notes, and snippets.

Embed
What would you like to do?
Post previews for Github Pages (a la wordpress)
{% for post in site.posts limit:5 %}
<div class="box">
<h3>{{post.title}}</h3>
<div class="clearfix"></div>
<div class="right big">
{% assign breakIndex = -1 %}
{% for element in post.content %}
{% if element contains '<!--more-->' %}
{% assign breakIndex = forloop.index %}
{% endif %}
{% endfor %}
{% for element in post.content limit: breakIndex %}
{{ element }}
{% endfor %}
<p><a href="{{post.url}}">Read this entry...</a></p>
</div>
</div>
{% endfor %}
@artgon

This comment has been minimized.

Copy link
Owner

artgon commented Nov 13, 2011

Since Github pages is using Liquid 2.2.0, there is no split tag. Therefore, I had to improvise this preview method. Since I imported all my posts from Wordpress, they are split using the "more" tag, as seen above.

@luin

This comment has been minimized.

Copy link

luin commented Dec 14, 2011

cool!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment