mirror of
https://github.com/jekyll/jekyll.git
synced 2026-01-30 17:28:29 -05:00
When a post does not contain an excerpt_separator, meaning the excerpt includes the entire post, the excerpt should contain exactly the post content. This is desirable both from a correctness standpoint, that the excerpt should not introduce any new content, and more practically to allow fast and easy detection of whole-post excerpts in Liquid templates using `post.excerpt == post.content`. A common use-case is deciding whether to render "Read More" links on a page containing post excerpts. This commit does exactly that. It avoids adding additional newlines to the excerpt content when the excerpt includes the whole post and adds tests to ensure that this behavior is correct and preserved going forward. Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
51 lines
2.6 KiB
Gherkin
51 lines
2.6 KiB
Gherkin
Feature: Post excerpts
|
|
As a hacker who likes to blog
|
|
I want to be able to make a static site
|
|
In order to share my awesome ideas with the interwebs
|
|
But some people can only focus for a few moments
|
|
So just give them a taste
|
|
|
|
Scenario: An excerpt without a layout
|
|
Given I have an "index.html" page that contains "{% for post in site.posts %}{{ post.excerpt }}{% endfor %}"
|
|
And I have a _posts directory
|
|
And I have the following posts:
|
|
| title | date | layout | content |
|
|
| entry1 | 2007-12-31 | post | content for entry1. |
|
|
When I run jekyll build
|
|
Then the _site directory should exist
|
|
And I should see exactly "<p>content for entry1.</p>" in "_site/index.html"
|
|
|
|
Scenario: An excerpt from a post with a layout
|
|
Given I have an "index.html" page that contains "{% for post in site.posts %}{{ post.excerpt }}{% endfor %}"
|
|
And I have a _posts directory
|
|
And I have a _layouts directory
|
|
And I have a post layout that contains "{{ page.excerpt }}"
|
|
And I have the following posts:
|
|
| title | date | layout | content |
|
|
| entry1 | 2007-12-31 | post | content for entry1. |
|
|
When I run jekyll build
|
|
Then the _site directory should exist
|
|
And the _site/2007 directory should exist
|
|
And the _site/2007/12 directory should exist
|
|
And the _site/2007/12/31 directory should exist
|
|
And the "_site/2007/12/31/entry1.html" file should exist
|
|
And I should see exactly "<p>content for entry1.</p>" in "_site/2007/12/31/entry1.html"
|
|
And I should see exactly "<p>content for entry1.</p>" in "_site/index.html"
|
|
|
|
Scenario: An excerpt from a post with a layout which has context
|
|
Given I have an "index.html" page that contains "{% for post in site.posts %}{{ post.excerpt }}{% endfor %}"
|
|
And I have a _posts directory
|
|
And I have a _layouts directory
|
|
And I have a post layout that contains "<html><head></head><body>{{ page.excerpt }}</body></html>"
|
|
And I have the following posts:
|
|
| title | date | layout | content |
|
|
| entry1 | 2007-12-31 | post | content for entry1. |
|
|
When I run jekyll build
|
|
Then the _site directory should exist
|
|
And the _site/2007 directory should exist
|
|
And the _site/2007/12 directory should exist
|
|
And the _site/2007/12/31 directory should exist
|
|
And the "_site/2007/12/31/entry1.html" file should exist
|
|
And I should see "<p>content for entry1.</p>" in "_site/index.html"
|
|
And I should see "<html><head></head><body><p>content for entry1.</p>\n</body></html>" in "_site/2007/12/31/entry1.html"
|