Filter latest articles: Time limit
This commit is contained in:
parent
e95efc69ce
commit
1ea3b38234
2 changed files with 6 additions and 2 deletions
|
|
@ -2,7 +2,7 @@ ErrorDocument 404 /404/index.html
|
|||
|
||||
RedirectMatch 303 ^/events/$ /events/<%= Time.now.year %>/
|
||||
RedirectMatch 303 ^/activities/$ /activities/<%= Time.now.year %>/
|
||||
RedirectMatch 303 ^/archives/articles/$ /archives/articles/<%= latest_articles(1)[0][:created_at].year %>/
|
||||
RedirectMatch 303 ^/archives/articles/$ /archives/articles/<%= Time.now.year %>/
|
||||
RedirectMatch 303 ^/archives/twitter/$ /archives/twitter/<%= twitter_grouped_by_month.keys.sort.last %>/
|
||||
|
||||
RedirectMatch 301 ^/wiki$ /
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
require 'date'
|
||||
|
||||
|
||||
def article_base_item(item)
|
||||
idparts = item.identifier.split('/')
|
||||
articleid = "/#{idparts[1]}/#{idparts[2]}/"
|
||||
|
|
@ -31,8 +34,9 @@ def sanitize_path(path)
|
|||
end
|
||||
|
||||
def latest_articles(max=nil)
|
||||
threshold = Date.today - 90 # Show articles for 90 days
|
||||
@cache_latest_art ||= @site.items.select do |p|
|
||||
p.attributes[:kind] == 'article'
|
||||
p.attributes[:kind] == 'article' and p.attributes[:created_at] > threshold
|
||||
end.sort do |a, b|
|
||||
a.attributes[:created_at] <=> b.attributes[:created_at]
|
||||
end.reverse
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue