add ordinal date permalink style (/YYYY/DDD/slug.html)
This commit is contained in:
parent
7376d66af2
commit
ea753130e6
|
@ -146,6 +146,8 @@ module Jekyll
|
|||
"/:categories/:title.html"
|
||||
when :date
|
||||
"/:categories/:year/:month/:day/:title.html"
|
||||
when :ordinal
|
||||
"/:categories/:year/:y_day/:title.html"
|
||||
else
|
||||
self.site.permalink_style.to_s
|
||||
end
|
||||
|
@ -170,6 +172,7 @@ module Jekyll
|
|||
"i_month" => date.strftime("%m").to_i.to_s,
|
||||
"categories" => categories.map { |c| URI.escape(c.to_s) }.join('/'),
|
||||
"short_month" => date.strftime("%b"),
|
||||
"y_day" => date.strftime("%j"),
|
||||
"output_ext" => self.output_ext
|
||||
}.inject(template) { |result, token|
|
||||
result.gsub(/:#{Regexp.escape token.first}/, token.last)
|
||||
|
|
|
@ -214,6 +214,18 @@ class TestPost < Test::Unit::TestCase
|
|||
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
|
||||
setup do
|
||||
@post.site.permalink_style = '/:categories/:year/:i_month/:i_day/:title/'
|
||||
|
|
Loading…
Reference in New Issue