-
-
Notifications
You must be signed in to change notification settings - Fork 39
Sort collection by last_modified_at #70
Comments
If it’s not a bug, it should definitely be a feature request! This happens to me too. It would be so useful to sort collections based on the last modification date and time. This is the error message I get (my collection is called "Jar")
Thanks a lot, this plugin is great! |
I've worked around this by adding a plugin that adds a string version, since that can be compared. Real comparisons would be even better! # frozen_string_literal: true
require 'fileutils'
require 'pathname'
require 'jekyll-last-modified-at'
module Recents
# Generate change information for all markdown pages
class Generator < Jekyll::Generator
def generate(site)
items = site.pages.select { |p| p.path.end_with? '.md' }
items.each do |page|
page.data['last_modified_at_str'] = Jekyll::LastModifiedAt::Determinator.new(site.source, page.path, '%FT%T%:z').to_s
end
end
end
end |
Hi @henryiii! I am no Ruby developer, but I am wondering how I could include not only |
items = site.pages.select { |p| p.path.end_with?('.md', '.html') } |
Thanks a lot! T |
Hi, I'm trying to display a list of notes ordered by most recently modified. I'm using this line: It's not creating an error as in the above posts, and it does seem to be sorting the notes based on something, but it doesn't seem to be the last modified date. In my list it shows the note title and {{ note.last_modified_at }} which seems to be correct, but it isn't sorted in that order. Is the issue my implementation, or just that the plugin isn't set up to do this? Here's my full template if that helps:
|
I'm trying to use this value to sort a custom collection called
docs
.{% assign sorted_docs = site.docs | sort: 'last_modified_at' | reverse %}
This causes:
The same happens if I remove the reverse. But it doesn't happen if I use other field to sort it (like
title
).Since it isn't documented I'm not sure if this can be used for sorting, should it work?
The text was updated successfully, but these errors were encountered: