Skip to content

Commit

Permalink
Allow Jekyll::Page to be excerpted with a Jekyll::Excerpt
Browse files Browse the repository at this point in the history
  • Loading branch information
parkr committed Feb 12, 2024
1 parent cf2d4f9 commit 090b765
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions lib/jekyll/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,20 @@ def trigger_hooks(hook_name, *args)
def write?
true
end

# The Page excerpt_separator, from the YAML Front-Matter or site
# default excerpt_separator value
#
# Returns the document excerpt_separator
def excerpt_separator
(data["excerpt_separator"] || site.config["excerpt_separator"]).to_s
end

# Whether to generate an excerpt
#
# Returns true if the excerpt separator is configured.
def generate_excerpt?
!excerpt_separator.empty?
end
end
end
2 changes: 1 addition & 1 deletion test/test_excerpt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def do_render(document)


should "produce a proper excerpt" do
assert_includes @excerpt.content, "I am the excerpt"
assert_equal @excerpt.content, "I am the excerpt\n\n"
end
end
end

0 comments on commit 090b765

Please sign in to comment.