Written by: steve ross on March 22nd 2011
Toto is an amazingly sleek, git-backed blogging engine. Coincidentally, the one on which this blog is based. The former incarnation of this blog pulled from a SQL database, and sorted by reverse chronological order. When pulling from the filesystem, as Toto does, the order of articles is undefined.
So, after reading the code for a minute or two, I settled on the following solution. In my archives.haml, which is the code that displays the articles list, I added a Ruby sort:
- if archives.length > 0
- for entry in archives.sort{|a, other| other[:date] <=> a[:date]}
%p
%a{:href => entry.path}
On
= entry.date
= entry.author
wrote:
= entry.title
The out-of-the box template omits the .sort{|a, other| other[:date] <=> a[:date]}.
blog comments powered by
Disqus