mirror of
https://github.com/jekyll/jekyll.git
synced 2026-01-31 01:38:24 -05:00
sort posts by reverse chronology
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user