Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't generate excerpts for non-html pages #8234

Merged
merged 3 commits into from Jun 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/jekyll/page.rb
Expand Up @@ -190,7 +190,7 @@ def excerpt_separator

def excerpt
return if excerpt_separator.empty? || !site.config["page_excerpts"]
return data["excerpt"] unless self.class == Jekyll::Page
return data["excerpt"] unless self.class == Jekyll::Page && html?

data["excerpt"] ||= Jekyll::PageExcerpt.new(self).to_liquid
end
Expand Down
4 changes: 4 additions & 0 deletions test/source/assets/test-styles.scss
@@ -0,0 +1,4 @@
---
---

@import "{{ site.skin | default: 'grid' }}";
4 changes: 2 additions & 2 deletions test/test_filters.rb
Expand Up @@ -816,7 +816,7 @@ def to_liquid
"The list of grouped items for '' is not an Array."
)
# adjust array.size to ignore symlinked page in Windows
qty = Utils::Platforms.really_windows? ? 16 : 18
qty = Utils::Platforms.really_windows? ? 18 : 20
assert_equal qty, g["items"].size
end
end
Expand Down Expand Up @@ -1310,7 +1310,7 @@ def to_liquid
"The list of grouped items for '' is not an Array."
)
# adjust array.size to ignore symlinked page in Windows
qty = Utils::Platforms.really_windows? ? 16 : 18
qty = Utils::Platforms.really_windows? ? 18 : 20
assert_equal qty, g["items"].size
end
end
Expand Down
7 changes: 7 additions & 0 deletions test/test_page.rb
Expand Up @@ -379,6 +379,13 @@ def do_render(page)
test_page = Jekyll::Page.new(configured_site, source_dir, "/contacts", "bar.html")
assert_equal "Contact Information\n", test_page.to_liquid["excerpt"]
end

should "not expose an excerpt for non-html pages even in a configured site" do
configured_site = fixture_site("page_excerpts" => true)
test_page = Jekyll::Page.new(configured_site, source_dir, "assets", "test-styles.scss")
refute_equal ".half { width: 50%; }\n", test_page.to_liquid["excerpt"]
assert_nil test_page.to_liquid["excerpt"]
end
end

context "generated via plugin" do
Expand Down
2 changes: 2 additions & 0 deletions test/test_site.rb
Expand Up @@ -241,6 +241,8 @@ def generate(site)
properties.html
sitemap.xml
static_files.html
test-styles.css.map
test-styles.scss
trailing-dots...md
)
unless Utils::Platforms.really_windows?
Expand Down