Merge pull request #1386 from mojombo/disable-excerpts

Disable automatically-generated excerpts with option
This commit is contained in:
Parker Moore 2013-08-08 02:39:06 -07:00
commit bc3dccf0e5
7 changed files with 41 additions and 5 deletions

View File

@ -255,7 +255,9 @@ module Jekyll
"page" => self.to_liquid(EXCERPT_ATTRIBUTES_FOR_LIQUID)
}.deep_merge(site_payload)
self.extracted_excerpt.do_layout(payload, {})
if generate_excerpt?
self.extracted_excerpt.do_layout(payload, {})
end
do_layout(payload.merge({"page" => self.to_liquid}), layouts)
end
@ -309,7 +311,15 @@ module Jekyll
protected
def extract_excerpt
Jekyll::Excerpt.new(self)
if generate_excerpt?
Jekyll::Excerpt.new(self)
else
""
end
end
def generate_excerpt?
!(site.config['excerpt_separator'].to_s.empty?)
end
end
end

View File

@ -2,3 +2,4 @@ pygments: true
relative_permalinks: false
gauges_id: 503c5af6613f5d0f19000027
permalink: /news/:year/:month/:day/:title
excerpt_separator:

View File

@ -27,5 +27,5 @@ See the [GitHub Release][] page for more a more detailed changelog for this rele
{% endfor %}
[GitHub Release]: https://github.com/mojombo/jekyll/releases/tag/v1.1.1
[gh-pages]: http://pages.github.com
[gh_pages]: http://pages.github.com
[v1_1_0]: https://github.com/mojombo/jekyll/releases/tag/v1.1.0

View File

@ -236,7 +236,7 @@ before your site is served.
Jekyll runs with the following configuration options by default. Unless
alternative settings for these options are explicitly specified in the
[[configuration]] file or on the command-line, Jekyll will run using these options.
configuration file or on the command-line, Jekyll will run using these options.
<div class="note warning">
<h5>There are two unsupported kramdown options</h5>

View File

@ -133,7 +133,8 @@ posts:
{% endhighlight %}
If you don't like the automatically-generated post excerpt, it can be overridden by adding
`excerpt` to your post's YAML front-matter.
`excerpt` to your post's YAML front-matter. Completely disable it by setting
your `excerpt_separator` to `""`.
## Highlighting code snippets

View File

@ -136,6 +136,14 @@ following error:
'{{ "{{" }}' was not properly terminated with regexp: /\}\}/ (Liquid::SyntaxError)
{% endhighlight %}
### Excerpts
Since v1.0.0, Jekyll has had automatically-generated post excerpts. Since
v1.1.0, Jekyll also passes these excerpts through Liquid, which can cause
strange errors where references don't exist or a tag hasn't been closed. If you
run into these errors, try setting `excerpt_separator: ""` in your
`_config.yml`, or set it to some nonsense string.
<div class="note">
<h5>Please report issues you encounter!</h5>
<p>If you come across a bug, please <a href="https://github.com/mojombo/jekyll/issues/new">create an issue</a> on GitHub describing the problem and any work-arounds you find so we can document it here for others.</p>

View File

@ -10,6 +10,22 @@ class TestExcerpt < Test::Unit::TestCase
post.render(layouts, {"site" => {"posts" => []}})
end
context "With extraction disabled" do
setup do
clear_dest
stub(Jekyll).configuration do
Jekyll::Configuration::DEFAULTS.merge({'excerpt_separator' => ''})
end
@site = Site.new(Jekyll.configuration)
@post = setup_post("2013-07-22-post-excerpt-with-layout.markdown")
end
should "not be generated" do
excerpt = @post.send(:extract_excerpt)
assert_equal true, excerpt.empty?
end
end
context "An extracted excerpt" do
setup do
clear_dest