-
Notifications
You must be signed in to change notification settings - Fork 244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Date sorting of articles on Index Page #66
Comments
i am having the same issue... any progress on this one yet? |
Toto sort articles by their basenames: def self.articles ext
Dir["#{Paths[:articles]}/*.#{ext}"].sort_by {|entry| File.basename(entry) }
end That means that you can override it in your module Toto
class Site
def self.articles ext
Dir["#{Paths[:articles]}/*.#{ext}"].sort_by {|entry| File.ctime(entry) }
end
end
end |
I don't think Git preserves the ctime of files, so when I deploy to heroku everything is all out of order with this script. I think a true fix would have to include the time as well as the date in the front matter. |
Hmm. Yes, git does not preserve ctime. @danielpcox your solution is the most obvious, I guess. Another option (or probably additional) is to proide a "sorting" block, so it would be possible to "override" default sorting policy (not sure is it needed or not). After all. Initial issue still can be solved without lots of modifictions :)) It's possible to put a special marker in the metadata: ts: 1316279620 And then while showing posts list you can sort articles like this: @articles.sort{ |a,b| (a.ts.nil? ? 1 : a.ts.to_i) <=> (b.ts.nil? ? 1 : b.ts.to_i) } Anyway, I like the ide about having time somehow. But (!) I believe it should not affect filenames. So for example I cn understand time in place of metadata nd then sort using that metadata, but not in the filenames. I believe that filename |
I'm not really interested in this feature (at least on the current codebase of toto - I believe we need to cleanup the core). But I have prepared possible solution as a separate branch. It has been tested, so I would like to get some responses (at least before I will merge it into my master). @micahwalter, @danielpcox your comments are very appreciated. Pull request: #101 |
The issue I am experiencing is this: I created two posts on the same date, the first with a lowercase title, the second with an uppercase title. The index page displays the first post above the second one, giving the impression that the first post was posted after the second one. I believe it is due to the fact that the index is sorted by date, then by slug. Since the page is sorting on the ASCII value of the slug, lowercase letters have a higher value than upper case values. I am going to fork toto and try to come up with a more accurate sorting algorithm for the index page, it might take a few ticks, I'm new to Ruby :]
JLank
The text was updated successfully, but these errors were encountered: