Adds excerpt to posts #837

Merged
merged 2 commits into from Mar 17, 2013

Projects

None yet

6 participants

@ixti
Member
ixti commented Mar 4, 2013

This is a rebased version of #727 with corrections requested by @mojombo

iotize commented Mar 9, 2013

👍 would love to see this merged.

Contributor

Cool idea however this would likely mess up a lot of old posts and would result in the loss of the first paragraph. I'd say this should be a plugin rather than a jekyll feature.

Member
ixti commented Mar 10, 2013

@AlexanderEkdahl How does it mess old posts? It just adds extra property excerpt to a post which is not obligatory to use.

Contributor

My bad. I thought it removed the first paragraph and put it in the excerpt variable.

I like it and need it for one of my sites. However, I'd still rather have it as a monkey-patch-plugin 😈

Owner
parkr commented Mar 11, 2013

@ixti I'm 👍 on this, but before I merge, what's the performance impact of this?

Member
ixti commented Mar 13, 2013

@parkr I don't know "exact numbers". It's needed to be tested on real big data. In general impact will be insignificant.

Owner
parkr commented Mar 16, 2013

If I have a lot of long posts, it'll probably be a significant performance impact. But, like you said, we need exact numbers.

Would you please update the documentation (in ./site) with this feature?

@mojombo mojombo commented on an outdated diff Mar 17, 2013
lib/jekyll/post.rb
+ #
+ # By default excerpt is your first paragraph of a post: everything before
+ # the first two new lines:
+ #
+ # ---
+ # title: Example
+ # ---
+ #
+ # First paragraph with [link][1].
+ #
+ # Second paragraph.
+ #
+ # [1]: http://example.com/
+ #
+ # This is fairly good option for Markdown and Textile files. But might cause
+ # problems for HTML posts (which is quiet unusual for Jekyll). If default
mojombo
mojombo Mar 17, 2013 Contributor

Spelling error: quiet should be quite.

@mojombo mojombo commented on an outdated diff Mar 17, 2013
lib/jekyll/post.rb
self.data['layout'] = 'post' unless self.data.has_key?('layout')
- self.data
+ nil
mojombo
mojombo Mar 17, 2013 Contributor

No need to explicitly return nil on methods marked as Returns nothing.. Just let it return whatever the last statement returns, the docs tell people not to trust the contents of the returned value for anything.

@mojombo mojombo commented on an outdated diff Mar 17, 2013
lib/jekyll/post.rb
@@ -109,6 +110,15 @@ def process(name)
raise FatalException.new("Post #{name} does not have a valid date.")
end
+ # Transform the contents and excerpt based on the content type.
+ #
+ # Returns nothing.
+ def transform
+ super
+ self.excerpt = converter.convert(self.excerpt)
+ nil
mojombo
mojombo Mar 17, 2013 Contributor

No need for explicit nil return. Just delete this line (see above comment).

Member
ixti commented Mar 17, 2013

@mojombo Fixed typo and explicit nil returns.
@parkr I don't know where to put that documentation (which section/post).

Owner
parkr commented Mar 17, 2013

Looks great to me! Your method documentation is enough of a starting point for us to update the site. Thanks man!

@parkr parkr merged commit 936ed1f into jekyll:master Mar 17, 2013

1 check passed

default The Travis build passed
Details
@parkr parkr added a commit that referenced this pull request Mar 17, 2013
@parkr parkr Update history to reflect merge of #837. 88f59c6
Member
ixti commented Mar 17, 2013

Awesome! Thanks!

@jekyllbot jekyllbot locked and limited conversation to collaborators Feb 27, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.