Excerpt relative-path should match its path (#6597)
Merge pull request 6597
This commit is contained in:
parent
da6a697cda
commit
5ebdc184c0
|
|
@ -8,7 +8,7 @@ module Jekyll
|
||||||
attr_accessor :content, :ext
|
attr_accessor :content, :ext
|
||||||
attr_writer :output
|
attr_writer :output
|
||||||
|
|
||||||
def_delegators :@doc, :site, :name, :ext, :relative_path, :extname,
|
def_delegators :@doc, :site, :name, :ext, :extname,
|
||||||
:render_with_liquid?, :collection, :related_posts,
|
:render_with_liquid?, :collection, :related_posts,
|
||||||
:url, :next_doc, :previous_doc
|
:url, :next_doc, :previous_doc
|
||||||
|
|
||||||
|
|
@ -41,6 +41,13 @@ module Jekyll
|
||||||
File.join(doc.path, "#excerpt")
|
File.join(doc.path, "#excerpt")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# 'Relative Path' of the excerpt.
|
||||||
|
#
|
||||||
|
# Returns the relative_path for the doc this excerpt belongs to with #excerpt appended
|
||||||
|
def relative_path
|
||||||
|
File.join(doc.relative_path, "#excerpt")
|
||||||
|
end
|
||||||
|
|
||||||
# Check if excerpt includes a string
|
# Check if excerpt includes a string
|
||||||
#
|
#
|
||||||
# Returns true if the string passed in
|
# Returns true if the string passed in
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,15 @@ class TestExcerpt < JekyllUnitTest
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "#relative_path" do
|
||||||
|
should "return its document's relative path with '/#excerpt' appended" do
|
||||||
|
assert_equal "#{@excerpt.doc.relative_path}/#excerpt",
|
||||||
|
@excerpt.relative_path
|
||||||
|
assert_equal "_posts/2013-07-22-post-excerpt-with-layout.markdown/#excerpt",
|
||||||
|
@excerpt.relative_path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "#to_liquid" do
|
context "#to_liquid" do
|
||||||
should "contain the proper page data to mimic the post liquid" do
|
should "contain the proper page data to mimic the post liquid" do
|
||||||
assert_equal "Post Excerpt with Layout", @excerpt.to_liquid["title"]
|
assert_equal "Post Excerpt with Layout", @excerpt.to_liquid["title"]
|
||||||
|
|
@ -86,7 +95,7 @@ class TestExcerpt < JekyllUnitTest
|
||||||
assert_equal Time.parse("2013-07-22"), @excerpt.to_liquid["date"]
|
assert_equal Time.parse("2013-07-22"), @excerpt.to_liquid["date"]
|
||||||
assert_equal %w(bar baz z_category MixedCase), @excerpt.to_liquid["categories"]
|
assert_equal %w(bar baz z_category MixedCase), @excerpt.to_liquid["categories"]
|
||||||
assert_equal %w(first second third jekyllrb.com), @excerpt.to_liquid["tags"]
|
assert_equal %w(first second third jekyllrb.com), @excerpt.to_liquid["tags"]
|
||||||
assert_equal "_posts/2013-07-22-post-excerpt-with-layout.markdown",
|
assert_equal "_posts/2013-07-22-post-excerpt-with-layout.markdown/#excerpt",
|
||||||
@excerpt.to_liquid["path"]
|
@excerpt.to_liquid["path"]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue