diff --git a/lib/jekyll/tags/post_url.rb b/lib/jekyll/tags/post_url.rb index dd02d3bf..6814c3ca 100644 --- a/lib/jekyll/tags/post_url.rb +++ b/lib/jekyll/tags/post_url.rb @@ -6,13 +6,15 @@ module Jekyll attr_accessor :date, :slug def initialize(name) - who, cares, date, slug = *name.match(MATCHER) - @slug = slug + all, path, date, slug = *name.sub(/^\//, "").match(MATCHER) + @slug = path ? path + slug : slug @date = Time.parse(date) end def ==(other) - slug == other.slug && + path = other.name.split("/")[0...-1].join("/") + otherslug = path != "" ? path + '/' + other.slug : other.slug + slug == otherslug && date.year == other.date.year && date.month == other.date.month && date.day == other.date.day diff --git a/test/source/_posts/es/2008-11-21-nested.textile b/test/source/_posts/es/2008-11-21-nested.textile new file mode 100644 index 00000000..6140a46e --- /dev/null +++ b/test/source/_posts/es/2008-11-21-nested.textile @@ -0,0 +1,8 @@ +--- +layout: default +title: Nested +--- + +url: {{ page.url }} +date: {{ page.date }} +id: {{ page.id }} \ No newline at end of file diff --git a/test/test_generated_site.rb b/test/test_generated_site.rb index 0861ee93..cb8b5486 100644 --- a/test/test_generated_site.rb +++ b/test/test_generated_site.rb @@ -14,7 +14,7 @@ class TestGeneratedSite < Test::Unit::TestCase end should "ensure post count is as expected" do - assert_equal 32, @site.posts.size + assert_equal 33, @site.posts.size end should "insert site.posts into the index" do diff --git a/test/test_site.rb b/test/test_site.rb index e8eb104d..f59c0ea9 100644 --- a/test/test_site.rb +++ b/test/test_site.rb @@ -162,7 +162,7 @@ class TestSite < Test::Unit::TestCase @site.read_posts('') posts = Dir[source_dir('_posts', '*')] posts.delete_if { |post| File.directory?(post) } - assert_equal posts.size - 1, @site.posts.size + assert_equal posts.size, @site.posts.size end should "deploy payload" do @@ -173,7 +173,7 @@ class TestSite < Test::Unit::TestCase posts.delete_if { |post| File.directory?(post) } categories = %w(bar baz category foo z_category publish_test win).sort - assert_equal posts.size, @site.posts.size + assert_equal posts.size + 1, @site.posts.size assert_equal categories, @site.categories.keys.sort assert_equal 4, @site.categories['foo'].size end diff --git a/test/test_tags.rb b/test/test_tags.rb index 0ba6b647..09dd1003 100644 --- a/test/test_tags.rb +++ b/test/test_tags.rb @@ -204,6 +204,27 @@ CONTENT end end + context "simple page with nested post linking" do + setup do + content = < 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true}) + end + + should "not cause an error" do + assert_no_match /markdown\-html\-error/, @result + end + + should "have the url to the \"complex\" post from 2008-11-21" do + assert_match %r{/2008/11/21/nested/}, @result + end + end + context "gist tag" do context "simple" do setup do