parent
4b57a4187e
commit
8b22c9dcd5
|
@ -35,6 +35,11 @@ If you have a lot of pages, you can organize them into subfolders. The same subf
|
||||||
|
|
||||||
You might want to have a particular folder structure for your source files that changes for the built site. With [permalinks](/docs/permalinks) you have full control of the output URL.
|
You might want to have a particular folder structure for your source files that changes for the built site. With [permalinks](/docs/permalinks) you have full control of the output URL.
|
||||||
|
|
||||||
|
## Excerpts for pages
|
||||||
|
|
||||||
|
From Jekyll 4.1.1 onwards, one can *choose* to generate excerpts for their pages by setting `page_excerpts` to `true` in their
|
||||||
|
config file.
|
||||||
|
|
||||||
## Liquid Representation
|
## Liquid Representation
|
||||||
|
|
||||||
From Jekyll 4.1 onwards, there is a minor change in how instances of `Jekyll::Page` are exposed to layouts and other Liquid
|
From Jekyll 4.1 onwards, there is a minor change in how instances of `Jekyll::Page` are exposed to layouts and other Liquid
|
||||||
|
|
|
@ -217,13 +217,14 @@ module Jekyll
|
||||||
end
|
end
|
||||||
|
|
||||||
def excerpt_separator
|
def excerpt_separator
|
||||||
@excerpt_separator ||= (data["excerpt_separator"] || site.config["excerpt_separator"]).to_s
|
@excerpt_separator ||= data["excerpt_separator"] || site.config["excerpt_separator"] || ""
|
||||||
end
|
end
|
||||||
|
|
||||||
def excerpt
|
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
|
||||||
|
|
||||||
data["excerpt"] ||= Jekyll::PageExcerpt.new(self).to_liquid unless excerpt_separator.empty?
|
data["excerpt"] ||= Jekyll::PageExcerpt.new(self).to_liquid
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -125,7 +125,7 @@ class TestPage < JekyllUnitTest
|
||||||
attrs = {
|
attrs = {
|
||||||
:content => "All the properties.\n",
|
:content => "All the properties.\n",
|
||||||
:dir => "/properties/",
|
:dir => "/properties/",
|
||||||
:excerpt => "All the properties.\n",
|
:excerpt => nil,
|
||||||
:foo => "bar",
|
:foo => "bar",
|
||||||
:layout => "default",
|
:layout => "default",
|
||||||
:name => "properties.html",
|
:name => "properties.html",
|
||||||
|
@ -405,9 +405,15 @@ class TestPage < JekyllUnitTest
|
||||||
end
|
end
|
||||||
|
|
||||||
context "read-in by default" do
|
context "read-in by default" do
|
||||||
should "expose an excerpt to Liquid templates" do
|
should "not expose an excerpt to Liquid templates" do
|
||||||
page = setup_page("/contacts", "bar.html")
|
page = setup_page("/contacts", "bar.html")
|
||||||
assert_equal "Contact Information\n", page.to_liquid["excerpt"]
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue