Path names for articles

This commit is contained in:
Stefan Schlott 2013-08-24 11:04:18 +02:00
parent 81e67956fb
commit a0163068af
2 changed files with 38 additions and 0 deletions

20
lib/articlehelpers.rb Normal file
View file

@ -0,0 +1,20 @@
def article_base_item(item)
idparts = item.identifier.split('/')
articleid = "/#{idparts[1]}/#{idparts[2]}/"
if idparts.length>3 then
result = @items[articleid]
if (!result)
raise Nanoc::Errors::GenericTrivial.new("Base article #{articleid} for item #{item.identifier} not found!")
end
result
else
item
end
end
def pathname_of_article(item)
idparts = item.identifier.split('/')
time = item[:created_at]
slug = idparts[2].sub( %r{^[0-9]*-}, "" )
time.strftime('%Y-%m-%d') + '-' + slug
end