Created
November 13, 2011 02:27
-
-
Save artgon/1361497 to your computer and use it in GitHub Desktop.
Post previews for Github Pages (a la wordpress)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% 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 %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.