From 96244e7d6fa0477a94d1f6f0ec1c48f58db00adc Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Sun, 7 Jun 2020 22:01:51 +0530 Subject: [PATCH 1/3] Don't generate excerpts for non-html pages --- lib/jekyll/page.rb | 2 +- test/test_page.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/jekyll/page.rb b/lib/jekyll/page.rb index 9bebbf1e779..b1b713a661d 100644 --- a/lib/jekyll/page.rb +++ b/lib/jekyll/page.rb @@ -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 diff --git a/test/test_page.rb b/test/test_page.rb index 1ea00381eda..ba513b2f251 100644 --- a/test/test_page.rb +++ b/test/test_page.rb @@ -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 From e4cc8ccf319843d508a0a69c17aebe6c462ee22a Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Mon, 8 Jun 2020 15:48:28 +0530 Subject: [PATCH 2/3] Add test asset file --- test/source/assets/test-styles.scss | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 test/source/assets/test-styles.scss diff --git a/test/source/assets/test-styles.scss b/test/source/assets/test-styles.scss new file mode 100644 index 00000000000..5c9e870dc74 --- /dev/null +++ b/test/source/assets/test-styles.scss @@ -0,0 +1,4 @@ +--- +--- + +@import "{{ site.skin | default: 'grid' }}"; From e7ca9da7c7eeb6869b200078e57bb25f080d73a5 Mon Sep 17 00:00:00 2001 From: Ashwin Maroli Date: Mon, 8 Jun 2020 12:48:19 +0530 Subject: [PATCH 3/3] Fix tests --- test/test_filters.rb | 4 ++-- test/test_site.rb | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test/test_filters.rb b/test/test_filters.rb index f491a8d3f0d..1136625a09d 100644 --- a/test/test_filters.rb +++ b/test/test_filters.rb @@ -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 @@ -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 diff --git a/test/test_site.rb b/test/test_site.rb index 122490e81d3..e0c7822f39c 100644 --- a/test/test_site.rb +++ b/test/test_site.rb @@ -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?