Merge pull request #928 from danieldriver/ordinal_date
add ordinal date permalink style (/YYYY/DDD/slug.html)
This commit is contained in:
commit
8bf55ef8fa
|
@ -146,6 +146,8 @@ module Jekyll
|
||||||
"/:categories/:title.html"
|
"/:categories/:title.html"
|
||||||
when :date
|
when :date
|
||||||
"/:categories/:year/:month/:day/:title.html"
|
"/:categories/:year/:month/:day/:title.html"
|
||||||
|
when :ordinal
|
||||||
|
"/:categories/:year/:y_day/:title.html"
|
||||||
else
|
else
|
||||||
self.site.permalink_style.to_s
|
self.site.permalink_style.to_s
|
||||||
end
|
end
|
||||||
|
@ -170,6 +172,7 @@ module Jekyll
|
||||||
"i_month" => date.strftime("%m").to_i.to_s,
|
"i_month" => date.strftime("%m").to_i.to_s,
|
||||||
"categories" => categories.map { |c| URI.escape(c.to_s) }.join('/'),
|
"categories" => categories.map { |c| URI.escape(c.to_s) }.join('/'),
|
||||||
"short_month" => date.strftime("%b"),
|
"short_month" => date.strftime("%b"),
|
||||||
|
"y_day" => date.strftime("%j"),
|
||||||
"output_ext" => self.output_ext
|
"output_ext" => self.output_ext
|
||||||
}.inject(template) { |result, token|
|
}.inject(template) { |result, token|
|
||||||
result.gsub(/:#{Regexp.escape token.first}/, token.last)
|
result.gsub(/:#{Regexp.escape token.first}/, token.last)
|
||||||
|
|
|
@ -214,6 +214,18 @@ class TestPost < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "with ordinal style" do
|
||||||
|
setup do
|
||||||
|
@post.site.permalink_style = :ordinal
|
||||||
|
@post.process(@fake_file)
|
||||||
|
end
|
||||||
|
|
||||||
|
should "process the url correctly" do
|
||||||
|
assert_equal "/:categories/:year/:y_day/:title.html", @post.template
|
||||||
|
assert_equal "/2008/253/foo-bar.html", @post.url
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "with custom date permalink" do
|
context "with custom date permalink" do
|
||||||
setup do
|
setup do
|
||||||
@post.site.permalink_style = '/:categories/:year/:i_month/:i_day/:title/'
|
@post.site.permalink_style = '/:categories/:year/:i_month/:i_day/:title/'
|
||||||
|
|
Loading…
Reference in New Issue