mirror of
https://github.com/jekyll/jekyll.git
synced 2026-02-07 05:05:10 -05:00
Make page excerpts consistent with doc excerpts (#8236)
Merge pull request 8236
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
---
|
||||
---
|
||||
|
||||
@import "{{ site.skin | default: 'grid' }}";
|
||||
---
|
||||
---
|
||||
|
||||
@import "{{ site.skin | default: 'grid' }}";
|
||||
|
||||
7
test/source/contacts/foo.md
Normal file
7
test/source/contacts/foo.md
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
title: Contact Information
|
||||
---
|
||||
|
||||
## {{ page.title }}
|
||||
|
||||
In case of emergency, contact Mr. John Doe, 1234, Foo Road, Foo.
|
||||
@@ -816,7 +816,7 @@ class TestFilters < JekyllUnitTest
|
||||
"The list of grouped items for '' is not an Array."
|
||||
)
|
||||
# adjust array.size to ignore symlinked page in Windows
|
||||
qty = Utils::Platforms.really_windows? ? 18 : 20
|
||||
qty = Utils::Platforms.really_windows? ? 19 : 21
|
||||
assert_equal qty, g["items"].size
|
||||
end
|
||||
end
|
||||
@@ -1310,7 +1310,7 @@ class TestFilters < JekyllUnitTest
|
||||
"The list of grouped items for '' is not an Array."
|
||||
)
|
||||
# adjust array.size to ignore symlinked page in Windows
|
||||
qty = Utils::Platforms.really_windows? ? 18 : 20
|
||||
qty = Utils::Platforms.really_windows? ? 19 : 21
|
||||
assert_equal qty, g["items"].size
|
||||
end
|
||||
end
|
||||
|
||||
@@ -369,22 +369,39 @@ class TestPage < JekyllUnitTest
|
||||
end
|
||||
|
||||
context "read-in by default" do
|
||||
should "not expose an excerpt to Liquid templates" do
|
||||
should "not initialize excerpts by default" do
|
||||
page = setup_page("contacts", "foo.md")
|
||||
assert_nil page.excerpt
|
||||
end
|
||||
|
||||
should "not expose an excerpt to Liquid templates by default" do
|
||||
page = setup_page("/contacts", "bar.html")
|
||||
assert_nil page.to_liquid["excerpt"]
|
||||
end
|
||||
|
||||
should "expose an excerpt to Liquid templates if site is configured to" do
|
||||
configured_site = fixture_site("page_excerpts" => true)
|
||||
test_page = Jekyll::Page.new(configured_site, source_dir, "/contacts", "bar.html")
|
||||
assert_equal "Contact Information\n", test_page.to_liquid["excerpt"]
|
||||
end
|
||||
context "in a site configured to generate page excerpts" do
|
||||
setup { @configured_site = fixture_site("page_excerpts" => true) }
|
||||
|
||||
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"]
|
||||
should "initialize excerpt eagerly but render only when needed" do
|
||||
test_page = Jekyll::Page.new(@configured_site, source_dir, "contacts", "foo.md")
|
||||
assert_equal Jekyll::PageExcerpt, test_page.data["excerpt"].class
|
||||
assert_equal String, test_page.excerpt.class
|
||||
assert_equal(
|
||||
"<h2 id=\"contact-information\">Contact Information</h2>\n",
|
||||
test_page.excerpt
|
||||
)
|
||||
end
|
||||
|
||||
should "expose an excerpt to Liquid templates" do
|
||||
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" do
|
||||
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
|
||||
end
|
||||
|
||||
|
||||
@@ -232,6 +232,7 @@ class TestSite < JekyllUnitTest
|
||||
environment.html
|
||||
exploit.md
|
||||
foo.md
|
||||
foo.md
|
||||
humans.txt
|
||||
index.html
|
||||
index.html
|
||||
|
||||
Reference in New Issue
Block a user