sort posts by reverse chronology
This commit is contained in:
parent
7c3cfad2df
commit
b2d2d09f95
|
@ -1,6 +1,8 @@
|
|||
module AutoBlog
|
||||
|
||||
class Post
|
||||
include Comparable
|
||||
|
||||
MATCHER = /^(\d+-\d+-\d+)-(.*)\.([^.]+)$/
|
||||
|
||||
def self.valid?(name)
|
||||
|
@ -20,6 +22,10 @@ module AutoBlog
|
|||
self.transform
|
||||
end
|
||||
|
||||
def <=>(other)
|
||||
self.date <=> other.date
|
||||
end
|
||||
|
||||
def process(name)
|
||||
m, date, slug, ext = *name.match(MATCHER)
|
||||
self.date = Time.parse(date)
|
||||
|
|
|
@ -70,7 +70,7 @@ module AutoBlog
|
|||
end
|
||||
|
||||
def site_payload
|
||||
{"site" => {"time" => Time.now, "posts" => self.posts}}
|
||||
{"site" => {"time" => Time.now, "posts" => self.posts.sort.reverse}}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue