Created
April 3, 2013 07:44
-
-
Save jwebcat/5299228 to your computer and use it in GitHub Desktop.
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
module Jekyll | |
class Excerpt < Liquid::Block | |
def render(context) | |
# Get the current post's post object | |
id = context["page"]["id"] | |
posts = context.registers[:site].posts | |
post = posts [posts.index {|post| post.id == id}] | |
# Put the block contents into the post's excerpt field, | |
# and also return those contents | |
post.data["excerpt"] = super | |
end | |
end | |
end | |
Liquid::Template.register_tag('excerpt', Jekyll::Excerpt) |
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 %} | |
{% if post.excerpt %} | |
{{ post.excerpt | markdownify }} | |
{% else %} | |
{{ post.content }} | |
{% endif %} | |
{% endfor %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment