Merge pull request #1386 from mojombo/disable-excerpts
Disable automatically-generated excerpts with option
This commit is contained in:
commit
bc3dccf0e5
|
@ -255,7 +255,9 @@ module Jekyll
|
||||||
"page" => self.to_liquid(EXCERPT_ATTRIBUTES_FOR_LIQUID)
|
"page" => self.to_liquid(EXCERPT_ATTRIBUTES_FOR_LIQUID)
|
||||||
}.deep_merge(site_payload)
|
}.deep_merge(site_payload)
|
||||||
|
|
||||||
|
if generate_excerpt?
|
||||||
self.extracted_excerpt.do_layout(payload, {})
|
self.extracted_excerpt.do_layout(payload, {})
|
||||||
|
end
|
||||||
|
|
||||||
do_layout(payload.merge({"page" => self.to_liquid}), layouts)
|
do_layout(payload.merge({"page" => self.to_liquid}), layouts)
|
||||||
end
|
end
|
||||||
|
@ -309,7 +311,15 @@ module Jekyll
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def extract_excerpt
|
def extract_excerpt
|
||||||
|
if generate_excerpt?
|
||||||
Jekyll::Excerpt.new(self)
|
Jekyll::Excerpt.new(self)
|
||||||
|
else
|
||||||
|
""
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def generate_excerpt?
|
||||||
|
!(site.config['excerpt_separator'].to_s.empty?)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,3 +2,4 @@ pygments: true
|
||||||
relative_permalinks: false
|
relative_permalinks: false
|
||||||
gauges_id: 503c5af6613f5d0f19000027
|
gauges_id: 503c5af6613f5d0f19000027
|
||||||
permalink: /news/:year/:month/:day/:title
|
permalink: /news/:year/:month/:day/:title
|
||||||
|
excerpt_separator:
|
||||||
|
|
|
@ -27,5 +27,5 @@ See the [GitHub Release][] page for more a more detailed changelog for this rele
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
[GitHub Release]: https://github.com/mojombo/jekyll/releases/tag/v1.1.1
|
[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
|
[v1_1_0]: https://github.com/mojombo/jekyll/releases/tag/v1.1.0
|
||||||
|
|
|
@ -236,7 +236,7 @@ before your site is served.
|
||||||
|
|
||||||
Jekyll runs with the following configuration options by default. Unless
|
Jekyll runs with the following configuration options by default. Unless
|
||||||
alternative settings for these options are explicitly specified in the
|
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">
|
<div class="note warning">
|
||||||
<h5>There are two unsupported kramdown options</h5>
|
<h5>There are two unsupported kramdown options</h5>
|
||||||
|
|
|
@ -133,7 +133,8 @@ posts:
|
||||||
{% endhighlight %}
|
{% endhighlight %}
|
||||||
|
|
||||||
If you don't like the automatically-generated post excerpt, it can be overridden by adding
|
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
|
## Highlighting code snippets
|
||||||
|
|
||||||
|
|
|
@ -136,6 +136,14 @@ following error:
|
||||||
'{{ "{{" }}' was not properly terminated with regexp: /\}\}/ (Liquid::SyntaxError)
|
'{{ "{{" }}' was not properly terminated with regexp: /\}\}/ (Liquid::SyntaxError)
|
||||||
{% endhighlight %}
|
{% 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">
|
<div class="note">
|
||||||
<h5>Please report issues you encounter!</h5>
|
<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>
|
<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>
|
||||||
|
|
|
@ -10,6 +10,22 @@ class TestExcerpt < Test::Unit::TestCase
|
||||||
post.render(layouts, {"site" => {"posts" => []}})
|
post.render(layouts, {"site" => {"posts" => []}})
|
||||||
end
|
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
|
context "An extracted excerpt" do
|
||||||
setup do
|
setup do
|
||||||
clear_dest
|
clear_dest
|
||||||
|
|
Loading…
Reference in New Issue