Merge pull request #998 from dhcole/master
Use post's directory path when matching for the post_url tag
This commit is contained in:
commit
290ba131e2
|
@ -6,13 +6,15 @@ module Jekyll
|
||||||
attr_accessor :date, :slug
|
attr_accessor :date, :slug
|
||||||
|
|
||||||
def initialize(name)
|
def initialize(name)
|
||||||
who, cares, date, slug = *name.match(MATCHER)
|
all, path, date, slug = *name.sub(/^\//, "").match(MATCHER)
|
||||||
@slug = slug
|
@slug = path ? path + slug : slug
|
||||||
@date = Time.parse(date)
|
@date = Time.parse(date)
|
||||||
end
|
end
|
||||||
|
|
||||||
def ==(other)
|
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.year == other.date.year &&
|
||||||
date.month == other.date.month &&
|
date.month == other.date.month &&
|
||||||
date.day == other.date.day
|
date.day == other.date.day
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
---
|
||||||
|
layout: default
|
||||||
|
title: Nested
|
||||||
|
---
|
||||||
|
|
||||||
|
url: {{ page.url }}
|
||||||
|
date: {{ page.date }}
|
||||||
|
id: {{ page.id }}
|
|
@ -14,7 +14,7 @@ class TestGeneratedSite < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
should "ensure post count is as expected" do
|
should "ensure post count is as expected" do
|
||||||
assert_equal 32, @site.posts.size
|
assert_equal 33, @site.posts.size
|
||||||
end
|
end
|
||||||
|
|
||||||
should "insert site.posts into the index" do
|
should "insert site.posts into the index" do
|
||||||
|
|
|
@ -162,7 +162,7 @@ class TestSite < Test::Unit::TestCase
|
||||||
@site.read_posts('')
|
@site.read_posts('')
|
||||||
posts = Dir[source_dir('_posts', '*')]
|
posts = Dir[source_dir('_posts', '*')]
|
||||||
posts.delete_if { |post| File.directory?(post) }
|
posts.delete_if { |post| File.directory?(post) }
|
||||||
assert_equal posts.size - 1, @site.posts.size
|
assert_equal posts.size, @site.posts.size
|
||||||
end
|
end
|
||||||
|
|
||||||
should "deploy payload" do
|
should "deploy payload" do
|
||||||
|
@ -173,7 +173,7 @@ class TestSite < Test::Unit::TestCase
|
||||||
posts.delete_if { |post| File.directory?(post) }
|
posts.delete_if { |post| File.directory?(post) }
|
||||||
categories = %w(bar baz category foo z_category publish_test win).sort
|
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 categories, @site.categories.keys.sort
|
||||||
assert_equal 4, @site.categories['foo'].size
|
assert_equal 4, @site.categories['foo'].size
|
||||||
end
|
end
|
||||||
|
|
|
@ -204,6 +204,27 @@ CONTENT
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "simple page with nested post linking" do
|
||||||
|
setup do
|
||||||
|
content = <<CONTENT
|
||||||
|
---
|
||||||
|
title: Post linking
|
||||||
|
---
|
||||||
|
|
||||||
|
{% post_url es/2008-11-21-nested %}
|
||||||
|
CONTENT
|
||||||
|
create_post(content, {'permalink' => '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 "gist tag" do
|
||||||
context "simple" do
|
context "simple" do
|
||||||
setup do
|
setup do
|
||||||
|
|
Loading…
Reference in New Issue