Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@artgon
Created November 13, 2011 02:27
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save artgon/1361497 to your computer and use it in GitHub Desktop.
Save artgon/1361497 to your computer and use it in GitHub Desktop.
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
Copy link
Author

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
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