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

3.9: Add more methods to Jekyll::Page that makes it more like a Document #9552

Open
wants to merge 1 commit into
base: 3.9-stable
Choose a base branch
from
Open
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
23 changes: 23 additions & 0 deletions lib/jekyll/page.rb
Expand Up @@ -198,5 +198,28 @@ def excerpt_separator
def generate_excerpt?
!excerpt_separator.empty?
end

# Determine whether the page is a YAML file.
#
# Returns true if the extname is either .yml or .yaml, false otherwise.
def yaml_file?
%w(.yaml .yml).include?(extname)
end

def previous_doc
end

def next_doc
end

def collection
Struct.new(:label).new("")
end

def id
@id ||= File.join(
*[@dir, (data["slug"] || File.basename(basename, ".*"))].map(&:to_s).reject(&:empty?)
)
end
end
end
21 changes: 21 additions & 0 deletions test/test_excerpt.rb
Expand Up @@ -317,5 +317,26 @@ def do_render(document)
should "produce a proper excerpt" do
assert_equal @excerpt.content, "I am the excerpt\n\n"
end

should "render" do
assert_equal @excerpt.output, "<p>I am the excerpt</p>\n\n"
end

should "support the drop" do
assert_equal @excerpt.to_liquid.to_h, {
"layout": nil,
"excerpt": nil,
"path": "page_with_excerpt.md/#excerpt",
"previous": nil,
"next": nil,
"output": "<p>I am the excerpt</p>\n\n",
"content": "<p>I am the excerpt</p>\n\n",
"collection": "",
"id": "/page_with_excerpt#excerpt",
"url": "/page_with_excerpt.html",
"relative_path": "page_with_excerpt.md/#excerpt",
"title": "I am a page with an excerpt"
}
end
end
end