Latest articles on start page
This commit is contained in:
parent
a0163068af
commit
714d02631f
2 changed files with 16 additions and 47 deletions
|
|
@ -18,3 +18,14 @@ def pathname_of_article(item)
|
|||
slug = idparts[2].sub( %r{^[0-9]*-}, "" )
|
||||
time.strftime('%Y-%m-%d') + '-' + slug
|
||||
end
|
||||
|
||||
|
||||
def latest_articles(max=nil)
|
||||
@cache_latest_art ||= @site.items.select do |p|
|
||||
p.attributes[:kind] == 'article'
|
||||
end.sort do |a, b|
|
||||
a.attributes[:created_at] <=> b.attributes[:created_at]
|
||||
end.reverse
|
||||
@cache_latest_art[0..(max ? max-1 : @cache_latest_art.length-1)]
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue